java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
我将这些包含在构建路径中:
- 所有 Spring 库
- Apache Tomcat 7.0 库
项目在启动过程中仍然失败:
SEVERE: 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:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
Jun 2, 2011 11:07:38 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
Jun 2, 2011 11:07:38 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
在 org.sprintframework.web-3.1.0.M1.jar 中,我可以看到org.springframework.web.context.ContextLoaderListener
。
Google 上有人说应该包含 spring.jar
,但我在 3.x 发行版中没有看到任何 spring.jar
。
Eclipse 3.6.2
Tomcat 7
编辑:Spring 论坛(离线)上有人说应该在项目属性中检查“自动更新依赖项”,但我在项目属性中没有看到类似的内容。
I included these in the Build Path:
- all Spring libs
- Apache Tomcat 7.0 library
The project still fails during startup:
SEVERE: 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:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
Jun 2, 2011 11:07:38 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
Jun 2, 2011 11:07:38 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
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)
In org.sprintframework.web-3.1.0.M1.jar
, I can see the org.springframework.web.context.ContextLoaderListener
.
Someone on Google says that spring.jar
should be included but I don't see any spring.jar
in 3.x distribution.
Eclipse 3.6.2
Tomcat 7
Edit: Someone on the Spring Forum (offline) said "Automatically update dependencies" should be checked in Project Properties but I don't see anything like that in project properties.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
对我来说,实际的解决方案是安装“m2e-wtp - WTP 的 Maven 集成”。在这种情况下,马塞洛的解决方案是不必要的。
The actual solution for me was to install the "m2e-wtp - Maven integration for WTP". The solution of Marcelo is not neccessary in that case.
如果上面的方法不起作用,请从侦听器类中删除 .class,即
if nothing from above works, remove the .class from the listener class i.e.
这对我有用..
右键单击 Maven Web 项目
单击“属性”菜单
在弹出窗口的左侧选择“部署程序集”
单击弹出窗口右侧的“添加...”按钮
现在又出现一个弹出窗口(New Assembly Directivies)
单击“Java 构建路径条目”
单击“下一步”按钮
单击“完成”按钮,现在自动关闭“新装配指令”弹出窗口
现在单击“应用”按钮和“确定”按钮
运行您的网络应用程序
This works for me ..
Right Click on maven web project
Click 'Properties'menu
Select 'Deployment Assembly' in left side of the popped window
Click 'Add...' Button in right side of the popped up window
Now appear one more popup window(New Assembly Directivies)
Click 'Java Build path entries'
Click 'Next' Button
Click 'Finish' Button, now atomatically close New Assemby Directivies popup window
Now click 'Apply' Button and Ok Button
Run your webapplication
当我使用 Gradle 在 IntelliJ 项目中更改 Hibernate 映射后,就发生了这种情况。简单地重建该项目对我来说很有效。
This happened to me after I made changes to my Hibernate mapping in an IntelliJ project using Gradle. Simply rebuilding the project worked for me.
当我的构建路径中有该库,但部署程序集中没有该库时,我得到了这个。另外当我缺少 context.xml 时。
I got this when I had the lib in my build path, but not in my deployment assembly. Also when I had a missing context.xml.
在 Eclipse 管理的 tomcat 中运行 Spring Web 应用程序时,我遇到了类似的问题。我通过在项目的 Web 部署程序集中添加 Maven 依赖项解决了这个问题。
您应该看到“Maven 依赖项”已添加到 Web 部署程序集定义中。
I had a similar problem when running a spring web application in an Eclipse managed tomcat. I solved this problem by adding maven dependencies in the project's web deployment assembly.
You should see "Maven Dependencies" added to the Web Deployment Assembly definition.
当我使用 Eclipse WDT 时,同样的事情时常发生在我身上。当这种情况发生在一个未经修改且之前正在运行的项目上时,这尤其令人沮丧。这就是我在最后一个场景中修复它的方法:
这通常可以解决您提到的问题。
Same thing happens to me from time to time when using Eclipse WDT. Its specialy frustrating when this happens to a unmodified and previously working project. This is what I do to fix it in this last scenario:
This usually fixes the issue you mention.
我用的是IntelliJ IDEA,编译成功,但是启动Tomcat时,却提示:
一开始,我以为JAR丢失了,但是它就位了。
解决方案:
文件>项目结构> Artifacts
,在Output Layout
右侧面板中双击Available Elements
名为Maven:...
的库,它将被移动到左侧窗格中的WEB-INF/lib
。接受并重新启动 Tomcat。
I used IntelliJ IDEA, compilation is successful, but when starting Tomcat, it says:
In the beginning, I thought the JAR was missing, but it was in place.
Solution:
File > Project Structure > Artifacts
, in theOutput Layout
double click in right panelAvailable Elements
the library named likeMaven:...
, it will be moved toWEB-INF/lib
in the left pane.Accept and restart Tomcat.
您可以尝试“清理 Tomcat 工作目录”或简单地“清理..”。这应该丢弃所有已发布的状态并从头开始重新发布。
You could try "Clean Tomcat Work Directory" or simply "Clean..". This supposed to discard all published state and republish from scratch.
这肯定是 Eclipse 相关的问题。
对我有用的是在 eclipse 服务器选项卡中创建一个新服务器。
然后在这个新服务器上运行您的应用程序,它应该可以工作。
This is surely Eclipse related issue.
The thing which worked for me is creating a new server in eclipse server tab.
Then run your application in this new server, it should work.
对于为 Tomcat 7 运行时配置的 eclipse 项目,我遇到了同样的问题
右键单击项目并转到项目属性。
单击“部署程序集”。我注意到我在编译时使用用户库创建的 spring 库 jar 丢失了。
只需添加 jar 即可,在 tomcat 启动期间您应该在控制台中看到没有错误
I was facing the same issue for a eclipse project configured for Tomcat 7 runtime
Right click on project and go to project properties.
Click on Deployment Assembly. I could notice that my spring library jars which I created during compile time with a user library was missing.
Just add the jars and you should see no errors in console during tomcat start up
您必须至少使用 spring-core 版本
3.2.8.RELEASE
。对于 Maven,请在
pom.xml
中设置:来源:http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cglib/core/SpringNamingPolicy.html,因为3.2.8.
You have to use at least version
3.2.8.RELEASE
of spring-core.For Maven, set in your
pom.xml
:Source: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cglib/core/SpringNamingPolicy.html, since 3.2.8.
如果上述所有方法都不起作用,请尝试以下操作。这对我有用。
从服务器中删除您的项目>重新启动服务器>将您的项目添加到服务器>重新启动服务器。
详细说明:
If everything mentioned above does not work try the following. It worked for me.
Remove your project from the server > Restart server > Add your project to server > Restart server.
Detailed Instruction:
如果您正在使用 Maven,则项目可能尚未构建。首先执行
mvn clean package
然后再次尝试重新部署。If you're using maven, perhaps the project aint built yet. First do a
mvn clean package
then try redeploying again.Eclipse Luna 的解决方案:
Solution for Eclipse Luna:
如果您使用 IntelliJ IDEA,并在 Tomcat 服务器上部署应用程序,它会显示:
在“文件”菜单下
If you are using IntelliJ IDEA, and deploy application on Tomcat Server, it says:
Under
其实这是Tomcat的问题。
只需转到项目的“lib”文件夹并将所有“Spring”相关的 jar 复制到此文件夹中。刷新您的项目,就可以开始了。
这个问题有时会持续存在,因为 tomcat 无法找到 Spring 核心类。
Actually this is a problem of Tomcat.
Just go to 'lib' folder of your project and copy your all 'Spring' related jars into this. Refresh your project and you are all good to go.
This problem sometime persists because tomcat is unable to locate Spring core classes.
对我来说,修复方法是右键单击我的 webapp 模块 >梅文>更新项目
For me the fix was to right click on my webapp module > Maven > Update Project
我也有同样的错误。我没有在我的 POM 文件中添加以下依赖项。
但我的项目甚至在我添加此依赖项之前就已经运行了。但在某一时刻它停止并开始给出与上述相同的错误。
如果有人无法解决此错误,他们也可以通过此解决 链接
I also had the same error. I had not added the below dependency in my POM file.
But My porject used to run even before I had added this dependency. But at one point it stopped and started giving the same above error.
If any one couldn't solve this error they can also solve by this link
我有同样的问题。我通过在 pom.xml 中添加 spring-web 依赖 解决了这个问题。
确保您使用的 spring-web jar 具有 ContextLoaderListener 类扩展 ContextLoader 实现 ServletContextListener 并驻留在包 org.springframework.web.context 中。我用的是3.0.4.RELEASE
I had the same issue. I resolved it by adding spring-web dependency in my pom.
Make sure you use spring-web jar which has ContextLoaderListener class extends ContextLoader implements ServletContextListener and reside in the package org.springframework.web.context. I used 3.0.4.RELEASE
我尝试了
至少暂时有效的唯一方法是将 Maven 依赖项添加到 Web 部署程序集定义
但这不会永远有效!几天后它就停止工作了。我的解决方案是删除 Maven 依赖项,应用更改并再次添加 Maven 依赖项。
我正在使用
- 日食朱诺
- 嵌入式maven
- 雄猫7
I tried the
The only thing that worked at least temporarily was to add Maven Dependencies to Web Deployment Assembly definition
But this does not work for ever! After a couple of days it stops working. My solution was to remove Maven Dependencies, apply change and add Maven Dependencies again.
I'm using
- eclipse Juno
- embedded maven
- tomcat 7
对于 gradle 用户,它适用于以下步骤
中的 Servers 选项卡停止并删除 tomcat 服务器
1) 从 eclipse
2) 从 tomcat 安装中清理 webapp 和工作目录 ,(参考,操作方法:清除 Tomcat 的缓存并修复过时的 JSP 问题)
3) 使用构建工具清理和 eclipsify 项目
$ ./gradlew clean eclipse
//为mvn
用户触发相应的命令,$ mvn clean package
4)在eclipse中配置一个新的Tomcat服务器,并且再次运行该项目。
For gradle users, It works with following steps
1) Stop and Delete tomcat server from Servers Tab in eclipse
2) clean webapp and work directory from tomcat installation , (Reference, How-To: Clear out Tomcat’s cache and fix outdated JSP problems)
3) clean and eclipsify project using build tool
$ ./gradlew clean eclipse
//fire respective command formvn
users,$ mvn clean package
4) configure a new Tomcat server in eclipse, and run the project again.
我也遇到了同样的问题....并通过以下步骤解决:
RC(右键单击网络项目)-->属性-->部署组装 -->添加--> Java 构建路径条目 -->下一步-->选择缺少的 jar 文件 -->下一个-->完成
应用程序正在成功运行...
i too faced the same problem.... and resolved by following the below steps:
RC(right click on web project) --> properties --> Deployment Assembly --> Add --> Java Build Path Entries --> Next --> select jar files which are missing --> next --> finish
Application is running successfully...
我有同样的问题,我已经使用上面提到的步骤解决了它。但是当我再次遇到这个问题时,我尝试以下操作,
RC(右键单击网络项目)-->属性-->部署组装 -->添加--> Java 构建路径条目 -->下一步-->
单击下一步后,它只是一个空白窗口,并且禁用了“下一步”和“完成”选项。现在我能做什么?
I have the same issue , and I have resolved it using the steps mentioned above.but no when I have this issue again and i try the following,
RC(right click on web project) --> properties --> Deployment Assembly --> Add --> Java Build Path Entries --> Next -->
after clicking on next its only a blank window with the options Next and Fnish disabled.What can I do now?
我遇到了同样的问题。
只需从配置中删除服务器,并在重新启动 Eclipse 后通过将其添加到服务器运行时环境中将其重新添加回来。
I faced the same problem.
Just removed the server from configuration and added it back after restarting eclipse by adding it to the server runtime environment.
我最喜欢的一种最适合这种情况的快速解决方案是简单地删除工作空间的 .metadata 文件夹并再次导入您的项目。如果您尝试所有其他选项,则不能保证成功。有时上述解决方案有效,有时您会花费宝贵的时间来修复此配置。
有一天,我决定清理我的工作站。我根据不同的客户将项目安排到合适的文件夹中。结果一切都乱了。花了一整天的时间,最终还是没有到固定的工作空间。第二天我只是删除了工作空间的.metadata文件夹并再次导入了所有项目。宾果游戏一切就绪。
One quick solution I prefer which I suited most for this situation is simply delete .metadata folder of your work space and import your projects again. If you try all other option it wont guarantee the success. Sometimes the above solutions work sometime you will spend your precious hours to fix this configuration.
One day i decided to clean my work station.I arranged the projects to their suitable folders according to different clients. As a result all got messed up. After spending a whole day it did not end up in a fixed work space. Next day I simply deleted the .metadata folder of the work space and imported all the projects again. Bingo all set.
如果您使用 Maven,请将
war
放入 pom.xml 中。在这种情况下,也许是用jar打包的
你必须在Deployment Assembly中有Maven libs
Put
<packaging>war</packaging>
in your pom.xml if you are using Maven.In that case, maybe it is with jar packaging
You must have Maven libs in Deployment Assembly
我每个季度都会遇到几次这样的情况。这次我在 git diff 中有一个最小的更改摘要,并在 eclipse 中将问题跟踪到重置类路径(缺少我的 WEB-INF/lib 依赖项)。每当我拉入或拉出父级/同级 Maven 项目时,似乎都会发生这种情况。
有人提到将 spring jar 添加到 tomcat Web 容器库 - 这没问题,并且是大多数 EE 服务器运行的方式。但是请注意,通过将 spring 放置在 tomcat 上的类加载器树中更高的位置,您将运行在高于 war 上下文的类加载器级别的位置。我建议您将库保留在 per/war 较低级别的类加载器中。
在 eclipse 中进行结构项目更改后,我们会在 .classpath 被截断后看到以下内容。
我的类路径已重置,WEB-INF/lib 依赖项已删除。
放回去
,你就会没事的。
谢谢
/迈克尔
I ran into this a couple times a quarter. This time I had a minimal change summary in my git diff and tracked the problem to a reset classpath (missing my WEB-INF/lib dependency) in eclipse. This seems to occur any time I pull in or pull out parent/sibling maven projects.
There are mentions of adding your spring jars to the tomcat web container lib - this is ok and is the way most EE servers run. However be aware that by placing spring higher in the classloader tree on tomcat you will be running higher than the classloader level of your war context. I recommend you leave the libs in a per/war lower level classloader.
We see the following after a truncated .classpath after a structural project change in eclipse.
My classpath was reset and the WEB-INF/lib dependency was removed.
put back
and you will be OK.
thank you
/michael
使用“更新项目配置”搞乱了项目的构建路径。
修复:打开“配置构建路径...”菜单(右键单击项目)并修复每个源文件夹的“包含/排除”选项。
这对我有用。
Using the "Update project configuartion" messed up the build path of the project.
Fix: Open the "configure build path..." menu (right click on the project) and fix the Included/Excluded options for each source folder.
That worked for me.
很多情况下是java方面的问题,jdk或jre或jsp版本与maven项目方面不同。
In many case It is java facet problem ,jdk or jre or jsp version is difference than maven project face.