Maven项目下报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ly_linyuan/article/details/79963839

报错:

严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

问题:
工程为maven工程,ContextLoaderListener类位于spring-web-3.1.0.RELEASE.jar包中,检查了maven的pom.xml,依赖引入正常,在工程Maven Dependencies视图中也能看到spring-web-3.1.0.RELEASE.jar包被正常引入进来了。

错误原因:
进入tomcat路径.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\下检查,发现工程部署后在WEB-INF文件夹下没有生成lib目录,正常情况下,会生成lib目录并把工程的所有依赖jar包都部署到该目录下。

解决步骤:
1.项目右击–选择Properties,再选择Deployment Assembly,右边点击Add按钮,在弹出的窗口中选择Java Build Path Entries
这里写图片描述

2.点击Next,选择Maven Dependencies
这里写图片描述

3.点击Finish,就把Maven Dependencies添加到Web应用结构中了

4.成功:重新部署工程,发现工程WEB-INF目录下自动生成了lib目录,并且所有的依赖jar包也都已经部署进来,问题解决。

如此错误:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

07-27

在eclipse下编译通过,运行时报如下错误。注:spring 1.2 Web Libraries已经加过了rn严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListenerrnjava.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListenerrn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)rn at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3617)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)rn at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1069)rn at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1162)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)rn at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)rn at java.lang.Thread.run(Thread.java:595)rn2006-7-27 15:55:47 org.apache.catalina.core.StandardContext listenerStart

Tomcat启动时,org.springframework.web.context.ContextLoaderListener报错

12-08

错误信息:rn2011-12-8 16:00:21 org.apache.catalina.core.StandardContext listenerStartrnSEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListenerrnjava.lang.ExceptionInInitializerErrorrn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:506)rn at java.lang.Class.newInstance0(Class.java:355)rn at java.lang.Class.newInstance(Class.java:308)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3787)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)rn at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)rn at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:145)rn at java.security.AccessController.doPrivileged(Native Method)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)rn at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:578)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:589)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.lang.IllegalStateException: Could not load 'ContextLoader.properties': class path resource [ContextLoader.properties] cannot be opened because it does not existrn at org.springframework.web.context.ContextLoader.(ContextLoader.java:138)rn ... 33 morernrn这个问题该怎么解决,谢谢!

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试