Kotlin NoClassDefFoundError con el método @RequestMapping de spring

Intento aprender algunos conceptos básicos de spring usando Kotlin + IntelliJ, y he encontrado algunos problemas. @RequestMapping método anotado (con parameters) causa una exception, mientras que el equivalente Java funciona perfectamente bien. El código de Kotlin funciona bien, pero solo sin el método "processFormTwo" (Convertir código de trabajo en kotlin no ayuda).

Aquí está el código:

@Controller class HelloWorldController { @RequestMapping("/showForm") fun showForm() = "helloworld-form" // this one works fine @RequestMapping("/processForm") fun processForm() = "helloworld" //this one doesn't @RequestMapping("/processFormTwo") fun processFormTwo(request: HttpServletRequest, model: Model): String { var theName = request.getParameter("studentName") theName = theName.toUpperCase() val result = "Yo! " + theName model.addAttribute("message", result) return "helloworld" } } 

Configuración:

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- Step 3: Add support for component scanning --> <context:component-scan base-package="com.luv2code.springdemo" /> <!-- Step 4: Add support for conversion, formatting and validation support --> <mvc:annotation-driven/> <!-- Step 5: Define Spring MVC view resolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".jsp" /> </bean> </beans> 

web.xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>spring-mvc-demo</display-name> <!-- Spring MVC Configs --> <!-- Step 1: Configure Spring MVC Dispatcher Servlet --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet --> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> 

logging de errores:

exception

javax.servlet.ServletException: Servlet.init () para el despachador de servlets lanzó la exception org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java: 79) org.apache.catalina.valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:502) org.apache.coyote.http11.AbstractHttp11Processor.process ( AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process (AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun (AprEndpoint.java:2521) org.apache. tomcat.util.net.AprEndpoint $ SocketProcessor.run (AprEndpoint.java:2510) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java: 617) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThr) ead.java:61) java.lang.Thread.run (Thread.java:745) causa raíz

org.springframework.beans.factory.BeanCreationException: error al crear bean con el nombre 'helloWorldController': error al introspect bean class [com.luv2code.springdemo.mvc.HelloWorldController] para los metadatos del método de búsqueda: no se pudo encontrar la class de la que depende; exception anidada es java.lang.NoClassDefFoundError: org.springframework.beans.factory.annotation.AutowinetworkingAnnotationBeanPostProcessor.determineCandidateConstructors Kotlin / TypeCastException (AutowinetworkingAnnotationBeanPostProcessor.java:269) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors (AbstractAutowireCapableBeanFactory.java: 1118) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:1091) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:513) org.springframework.beans.factory. support.AtracttractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:483) org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:306) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleto n (DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:302) org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:197) org. springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:761) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:867) org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext. java: 543) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext (FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet. createWebApplicationContext (FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebAppli cationContext (FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init (HttpServletBean.java:171) javax.servlet.GenericServlet. init (GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:79) org.apache.catalina. valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:502) org.apache.coyote.http11.AbstractHttp11Processor.process (AbstractHttp11Processor.java:1132) org. apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process (AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun (AprEndpoint.java:2521) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run (AprEndpoint.java:2510) java.util.concurrent.ThreadPoolExecutor.runWo rker (ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61) java. lang.Thread.run (Thread.java:745) causa raíz

java.lang.NoClassDefFoundError: kotlin / TypeCastException java.lang.Class.getDeclanetworkingMethods0 (método nativo) java.lang.Class.privateGetDeclanetworkingMethods (Class.java:2701) java.lang.Class.getDeclanetworkingMethods (Class.java:1975) org. springframework.util.ReflectionUtils.getDeclanetworkingMethods (ReflectionUtils.java:613) org.springframework.util.ReflectionUtils.doWithMethods (ReflectionUtils.java:524) org.springframework.util.ReflectionUtils.doWithMethods (ReflectionUtils.java:510) org.springframework. beans.factory.annotation.AutowinetworkingAnnotationBeanPostProcessor.determineCandidateConstructors (AutowinetworkingAnnotationBeanPostProcessor.java:247) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors (AbstractAutowireCapableBeanFactory.java:1118) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance ( AbstractAutowireCapableBeanFactory.java:1091) org.springframework.beans.factory.support.AbstractAutowireCapabl eBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:513) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:483) org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:306 ) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:302) org.springframework.beans.factory.support .AbstractBeanFactory.getBean (AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:761) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:867) org .springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:5 43) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext (FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext ( FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext (FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:494) org.springframework.web.servlet. HttpServletBean.init (HttpServletBean.java:171) javax.servlet.GenericServlet.init (GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:504) org.apache.catalina.valves. ErrorReportValve.invoke (ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:502) org.apach e.coyote.http11.AbstractHttp11Processor.process (AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process (AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun ( AprEndpoint.java:2521) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run (AprEndpoint.java:2510) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) java.util.concurrent. ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61) java.lang.Thread.run (Thread.java:745) causa raíz

java.lang.ClassNotFoundException: kotlin.TypeCastException org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1333) org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1167) java.lang.Class .getDeclanetworkingMethods0 (método nativo) java.lang.Class.privateGetDeclanetworkingMethods (Class.java:2701) java.lang.Class.getDeclanetworkingMethods (Class.java:1975) org.springframework.util.ReflectionUtils.getDeclanetworkingMethods (ReflectionUtils.java:613) org.springframework.util.ReflectionUtils.doWithMethods (ReflectionUtils.java:524) org.springframework.util.ReflectionUtils.doWithMethods (ReflectionUtils.java:510) org.springframework.beans.factory.annotation.AutowinetworkingAnnotationBeanPostProcessor.determineCandidateConstructors (AutowinetworkingAnnotationBeanPostProcessor.java: 247) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors (AbstractAutowireCapableBeanFactory.java:1118) org.springframework. beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:1091) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:513) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( AbstractAutowireCapableBeanFactory.java:483) org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:306) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:230) org.springframework .beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:302) org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:761) org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:867) org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext (FrameworkServlet.java:668) org.springframework. web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext (FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init (HttpServletBean.java:171) javax.servlet.GenericServlet.init (GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValv e.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:502) org.apache.coyote.http11. AbstractHttp11Processor.process (AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process (AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun (AprEndpoint.java:2521) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run (AprEndpoint.java:2510) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor $ Worker.run ( ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61) java.lang.Thread.run (Thread.java:745)