2012-10-23 93 views
1

我開發了一個應用程序與春天3.0,它工作正常。spring mvc:註解驅動的java.lang.NoClassDefFoundError:javax/servlet/AsyncListener

我需要使用<mvc:annotation-driven/>的一些功能,當我將它包含在配置文件中時,我收到錯誤。

下面

是我所使用的代碼和錯誤:

<?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:tx="http://www.springframework.org/schema/tx" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

    <mvc:annotation-driven /> 
...... 
</beans> 

堆棧跟蹤:

java.lang.NoClassDefFoundError: javax/servlet/AsyncListener 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClassCond(Unknown Source) 
    at java.lang.ClassLoader.defineClass(Unknown Source) 
    at java.security.SecureClassLoader.defineClass(Unknown Source) 
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2527) 
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361) 
    at java.lang.Class.getDeclaredMethods0(Native Method) 
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source) 
    at java.lang.Class.getDeclaredMethods(Unknown Source) 
    at org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:159) 
    at org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:104) 
    at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87) 
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:233) 
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203) 
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:622) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) 
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:634) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:591) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:648) 
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:511) 
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:452) 
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133) 
    at javax.servlet.GenericServlet.init(GenericServlet.java:212) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) 
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) 
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187) 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) 
    at org.apache.catalina.core.StandardService.start(StandardService.java:519) 
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncListener 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361) 
    ... 42 more 
Oct 23, 2012 9:24:23 PM org.apache.catalina.core.StandardContext loadOnStartup 
+0

您是否將th Servlet 3.0 jar文件添加到應用程序的類路徑中? –

回答

2

如果使用方面:組件掃描「嘗試改變它添加以基礎包裝「。」*「 作爲樣本:

"<context:component-scan base-package="controller.*/>" 
相關問題