首页 > 代码库 > 【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

今天搭建新的项目,虽然在web.xml中配置了ContextLoaderListener以及IntrospectorCleanupListener

如下:

web.xml中部分代码:

技术分享
 1 <!-- 监听servletContext,启动contextConfigLocation中的spring配置信息 -->
 2     <listener>
 3         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 4     </listener>
 5 
 6 
 7     <!-- 防止spring内存溢出监听器   可用可不用-->
 8     <listener>
 9         <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
10     </listener>
View Code

但是,在项目启动的时候,依旧报错:

技术分享
 1 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
 2 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
 3     at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
 4     at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
 5     at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:511)
 6     at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:492)
 7     at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
 8     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4676)
 9     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5216)
10     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
11     at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1386)
12     at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1350)
13     at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
14     at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:280)
15     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
16     at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1164)
17     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1388)
18     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392)
19     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1360)
20     at java.lang.Thread.run(Unknown Source)
21 五月 15, 2017 8:44:23 下午 org.apache.catalina.core.StandardContext listenerStart
22 严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener
23 java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
24     at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
25     at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
26     at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:511)
27     at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:492)
28     at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
29     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4676)
30     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5216)
31     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
32     at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1386)
33     at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1350)
34     at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
35     at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:280)
36     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
37     at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1164)
38     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1388)
39     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392)
40     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1360)
41     at java.lang.Thread.run(Unknown Source)
View Code

 

解决方法:

项目上,右键 properties,选择进入Deployment Assembly,

技术分享

然后将Maven库的架包 也选择部署,这样项目就能读取到相关的架包,就可以正常启动而不会因为找不到   某些类         

技术分享

 

 

 

技术分享

 

【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener