2013-01-18 67 views
0

IM具有一些異常,同時運行的Spring應用程序我不知道爲什麼它的發生,請幫助我我已經在我的系統中導入的應用程序並嘗試運行,但它顯示了這個錯誤,請幫我指點迷津出來NoClassDefFoundError的:使用javax/servlet的/ AsyncListener

java.lang.NoClassDefFoundError: javax/servlet/AsyncListener 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620) 
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854) 
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) 
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) 
    at java.lang.Class.getDeclaredMethods0(Native Method) 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) 
    at java.lang.Class.getDeclaredMethods(Class.java:1791) 
    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:1206) 
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
    at java.lang.Thread.run(Thread.java:619) 

這是web.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 
    <display-name>EmployeeWebSpring</display-name> 


    <!-- The front controller of this Spring Web application, responsible for 
     handling all application requests --> 
    <servlet> 
     <servlet-name>ds</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 

     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <!-- Map all requests to the DispatcherServlet for handling --> 
    <servlet-mapping> 
     <servlet-name>ds</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 

    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 

    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>*.css</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>*.js</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>*.gif</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>*.jpg</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>*.png</url-pattern> 
    </servlet-mapping> 


</web-app> 

這是DS-servlet.xml中

<?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:p="http://www.springframework.org/schema/p" 
    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-3.2.xsd 
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.2.xsd 
          http://www.springframework.org/schema/mvc 
          http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> 

    <context:annotation-config /> 

    <mvc:annotation-driven /> 

    <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" 
     id="dataSource"> 
     <property value="com.mysql.jdbc.Driver" name="driverClassName" /> 
     <property value="jdbc:mysql://192.168.25.30:3306/employee" 
      name="url" /> 
     <property value="hr" name="username" /> 
     <property value="hr123" name="password" /> 
    </bean> 
    <bean id="employeeDaoImpl" class="com.nousinfo.tutorial.employee.dao.impl.EmployeeDAOImpl"> 
     <property name="dataSource" ref="dataSource" /> 
    </bean> 
    <bean id="departmentDaoImpl" 
     class="com.nousinfo.tutorial.employee.dao.impl.DepartmentDAOImpl"> 
     <property name="dataSource" ref="dataSource" /> 
    </bean> 
    <bean id="projectDaoImpl" class="com.nousinfo.tutorial.employee.dao.impl.ProjectDAOImpl"> 
     <property name="dataSource" ref="dataSource" /> 
    </bean> 

    <bean id="employeserviceImpl" class=" com.nousinfo.tutorial.service.impl.EmployeeServiceImpl"> 
     <property name="daoImpl" ref="employeeDaoImpl" /> 
    </bean> 
    <bean id="departmentserviceImpl" 
     class=" com.nousinfo.tutorial.service.impl.DepartmentServiceImpl"> 
     <property name="departmentDAOImpl" ref="departmentDaoImpl" /> 
    </bean> 

    <bean id="projectserviceImpl" class=" com.nousinfo.tutorial.service.impl.ProjectServiceImpl"> 
     <property name="projectDAOImpl" ref="projectDaoImpl" /> 
    </bean> 



    <bean id="mycontroller" 
     class="com.nousinfo.tutorial.controllers.SearchEmployeeController"> 
     <property name="employeeServiceImpl" ref="employeserviceImpl"></property> 
    </bean> 
    <bean id="emplController" class="com.nousinfo.tutorial.controllers.EmployeeController"> 
     <property name="employeeServiceImpl" ref="employeserviceImpl" /> 
     <property name="projectServiceImpl" ref="projectserviceImpl" /> 

    </bean> 
    <bean id="deaprtmentController" class="com.nousinfo.tutorial.controllers.DepartmentController"> 
     <property name="departmentServiceImpl" ref="departmentserviceImpl"></property> 
    </bean> 

    <bean id="deptCotrooler" 
     class="com.nousinfo.tutorial.controllers.SearchDepartmentController"> 
     <property name="departmentServiceImpl" ref="departmentserviceImpl"></property> 
    </bean> 
    <bean id="projectController" class="com.nousinfo.tutorial.controllers.ProjectController"> 
     <property name="projectServiceImpl" ref="projectserviceImpl"></property> 
    </bean> 
    <bean id="projectSearchController" 
     class="com.nousinfo.tutorial.controllers.SearchProjectController"> 
     <property name="projectServiceImpl" ref="projectserviceImpl"></property> 
    </bean> 




    <bean id="configurationLoader" 
     class="org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader" /> 
    <bean id="validator" class="org.springmodules.validation.bean.BeanValidator" 
     p:configurationLoader-ref="configurationLoader" /> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
     p:prefix="/WEB-INF/" p:suffix=".jsp" /> 

    <bean id="messageSource" 
     class="org.springframework.context.support.ResourceBundleMessageSource"> 
     <property name="basename" value="com/nousinfo/resources/messages" /> 
    </bean> 
    <!-- Configure the multipart resolver --> 
    <bean id="multipartResolver" 
     class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> 
    </bean> 








    <!-- configuring BeanNameViewResolver --> 
    <!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"></bean> 
     configuring exception Resolver <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> 
     <property name="exceptionMappings"> <props> <prop key="org.springframework.dao.DAOException">dberrorView</prop> 
     <prop key="java.lang.NumberFormatException">notANumber</prop> </props> </property> 
     </bean> configuring views required to render the view for /search.spring 
     <bean name="successSingleEmp" class="org.springframework.web.servlet.view.JstlView"> 
     <property name="url" value="/WEB-INF/EmployeeDetail.jsp" /> </bean> <bean 
     name="successMultipleEmps" class="org.springframework.web.servlet.view.JstlView"> 
     <property name="url" value="/WEB-INF/EmployeeList.jsp" /> </bean> <bean name="dberrorView" 
     class="org.springframework.web.servlet.view.JstlView"> <property name="url" 
     value="/WEB-INF/DBError.jsp" /> </bean> <bean name="notANumber" class="org.springframework.web.servlet.view.JstlView"> 
     <property name="url" value="/WEB-INF/NotANumberError.jsp" /> </bean> CONFIGURING 
     THE MEASSAGE RESOURCES FOR THIS APPLICTION CONTEXT <bean id="messageSource" 
     class="org.springframework.context.support.ResourceBundleMessageSource"> 
     <property name="basename" value="/com/nousinfo/resources/ApplicationResources" 
     /> </bean> --> 
</beans> 

回答

1

您正在使用2.5 Servlet規範,同時AsyncListener自帶3.0的servlet。

+0

如何與現有的配置 – henrycharles

+0

確保你的servlet容器中刪除此支持3.0規範([鏈接](http://tomcat.apache.org/whichversion.html)爲Tomcat,Jetty的8和9)。 XSI:然後在web.xml中使用3.0版本的schemaLocation =「http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd 「,version =」3.0「。如果您使用maven,請查看依賴關係。 – madhead

相關問題