Log4jConfigListener cannot be found -- context fails to start

56,728

Solution 1

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.

Solution 2

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"

Solution 3

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

Solution 4

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

Solution 5

Migrating to log4j2?

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

Share:
56,728
1000Suns
Author by

1000Suns

Updated on December 29, 2020

Comments

  • 1000Suns
    1000Suns over 3 years

    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