找不到 Log4jConfigListener -- 上下文无法启动
我正在尝试在 Eclipse 上设置一个 Web 应用程序。我使用的是 Tomcat 6.0 和 JDK 1.6.0_23。由于某种未知的原因,我收到此错误:
SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) 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:445) 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(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Jan 24, 2011 11:44:08 AM org.apache.catalina.core.StandardContext listenerStart 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:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) 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:445) 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(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
我检查了所有库是否已添加到构建路径中,并且一切似乎都是正确的。包含 log4j-1.2.15.jar
以及所有必需的 Spring 库。
我很困惑,尤其是导致问题的原因,因为该项目在另一台计算机上运行良好。任何有关此问题的帮助将不胜感激。
纳夫塔尔
I am trying to set up a Web application on Eclipse. I am using Tomcat 6.0 and JDK 1.6.0_23. For some unknown reason, I am getting this error:
SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) 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:445) 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(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Jan 24, 2011 11:44:08 AM org.apache.catalina.core.StandardContext listenerStart 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:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) 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:445) 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(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
I checked if all libraries have been added to the build path, and everything seems to be correct. The log4j-1.2.15.jar
is included and all the necessary Spring libraries.
I am very confused, especially to what causes the problem, as the project was working fine on another computer. Any help with this problem will be highly appreciated.
Naftal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
org.springframework.web.util.Log4jConfigListener 类绝对不在您的类路径中。
我建议的第一件事是,将 Tomcat 中的日志记录级别(在 conf 文件夹中)调至“ALL”或“DEBUG”,以便您可以准确地看到容器中发生的阻止此类的情况免遭被发现。
其次,如果在 linux/mac 上,我建议您通过运行 grep 来检查 JAR 文件中是否有缺少的类文件:
上述命令将返回包含该包的所有 JAR 文件。一旦 JAR 文件被隔离,您就可以进一步排除故障。
第三,确保你们之间没有任何冲突。类路径中存在多个版本的 Log4j 将会造成严重破坏。如果有 2 个 org.springframework.web.util.Log4jConfigListener 包,系统如何知道要加载哪个? Tomcat 有 3 个不同的类路径文件夹:
确保这些文件夹之一中只有一个 log4j JAR 文件。
The org.springframework.web.util.Log4jConfigListener class is definitely not in your classpath.
The first thing I would suggest is that you turn up the logging level in Tomcat -- in the conf folder -- to "ALL" or "DEBUG" so that you can see exactly what is going on in the container that is preventing this class from being found.
Second, I'd recommend you check your JAR files for the missing class file by running grep, if on linux/mac:
The above command will return all JAR files that contain that package. Once the JAR file is isolated, then you can further troubleshoot.
Third, make sure you don't have any conflicts. Multiple versions of Log4j being in your classpath will wreak havoc. How is the system supposed to know which org.springframework.web.util.Log4jConfigListener package to load if there are 2 of them? Tomcat has 3 different classpath folders:
Make sure you have only one log4j JAR file in only one of these folders.
Reticulogic的第二个建议是正确的。但是,在 Eclipse Helios 中,“Java EE 模块依赖项”选项已被删除。 Helios 的修复如下:
Reticulogic's second suggestion is correct. However, in Eclipse Helios, the "Java EE Module Dependencies" option has been removed. The fix for Helios is as follows:
不要忘记检查 webapp/WEB-INF/web.xml(Web 应用程序部署描述符)是否有无关的事件侦听器定义。
Don't forget to check your webapp/WEB-INF/web.xml (Web Application Deployment Descriptor) for extraneous Event Listener definitions.
如果您使用 maven 和 eclipse
1) 查看您的 Web 项目 .classpath 文件。如果您有类路径条目“org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER”,请确保该属性也存在。
2) 如果这不起作用,请右键单击 Eclipse 中的 Web 项目,然后转到“属性”-->“JavaEE 模块依赖项”。确保选中 Maven 依赖项框。
然后保存,构建部署yada yada
If you are using maven and eclipse
1) Look in your web project .classpath file. If you have a classpath entry "org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER", then make sure the attribute is there as well.
2) If that does not work, then right click on your web project in eclipse and go to Properties-->JavaEE Module dependencies. Make sure the Maven Dependencies box is checked.
Then save, build deploy yada yada
一个简单的解决方案是清理 Eclipse 中的 Tomcat 目录。这对我有用。
A simple solution is to clean the Tomcat directory in Eclipse. It worked for me.
如果您使用 log4j2,您可以在
package.json 中找到这些类。
If you use, log4j2, you can find these classes in
package.
从类名中可以看出
org.springframework.web.util.Log4jConfigListener
是spring框架的一部分。从 spring 4.2.1 开始它就被废弃了。所以检查你的 spring 版本。
As you can see from the class name
org.springframework.web.util.Log4jConfigListener
is part of spring framework.And it was depricated since spring 4.2.1 . So check your spring version.