14
votes

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 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 correct. log4j-1.2.15.jar is included and all the necessary spring libraries.

I am very confused as to what the problem especially because the project was working fine in another computer. Any help with this problem will be highly appreciated.

Naftal

6
can you list out libraries you have includedjmj
I am using Hibernate so I have hibernate libraries such as hibernate-annotations.jar, hibernate3.jar etc. But according to the stacktrace, it seems I am missing one of the springframework librabries. I have these spring libraries:- spring.jar, spring-aop.jar, spring-aspects.jar, spring-beans.jar, spring-context.jar, spring-context-support.jar, spring-core.jar, spring-jdbc.jar, spring-test.jar, spring-web.jar, spring-webmvc.jar1000Suns
ok then there is no spring jar ,is it ?jmj

6 Answers

41
votes

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:

  1. Right click on your project in Eclipse and go to Properties-->Deployment Assembly
  2. Click "Add..."
  3. Select "Java Build Path Entries" and click "Next"
  4. select "Maven Dependencies" and click "Finish"
5
votes

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:

  # run at the root of your lib folders:
  grep -ri "org.springframework.web.util.Log4jConfigListener" *

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:

 shared/lib
 lib
 webapps/yourapp/WEB-INF/lib

Make sure you have only one log4j JAR file in only one of these folders.

4
votes

A simple solution is to clean the Tomcat directory in Eclipse. It worked for me.

3
votes

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.

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

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

2
votes

Migrating to log4j2?

Don't forget to check your webapp/WEB-INF/web.xml (Web Application Deployment Descriptor) for extraneous Event Listener definitions.

0
votes

If you use, log4j2, you can find these classes in

org.apache.logging.log4j.web.*

package.