Announcement Announcement Module
Collapse
No announcement yet.
Could not initialize class org.apache.log4j.LogManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not initialize class org.apache.log4j.LogManager

    Hello, I have a problem with log4j Im using libary log4j1.2.14.jar and I get this error altough libary exist in my application /WEB-INF/lib folder. Any sugestion? It is a litle bit confusing, when spring jars ale loaded and log4j.jar not.

    java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
    at org.springframework.util.Log4jConfigurer.shutdownL ogging(Log4jConfigurer.java:117)
    at org.springframework.web.util.Log4jWebConfigurer.sh utdownLogging(Log4jWebConfigurer.java:170)
    at org.springframework.web.util.Log4jConfigListener.c ontextDestroyed(Log4jConfigListener.java:51)
    at org.apache.catalina.core.StandardContext.listenerS top(StandardContext.java:3882)
    at org.apache.catalina.core.StandardContext.stop(Stan dardContext.java:4523)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4387)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.access$000( ContainerBase.java:123)
    at org.apache.catalina.core.ContainerBase$PrivilegedA ddChild.run(ContainerBase.java:145)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:769)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirec tory(HostConfig.java:926)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:889)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1149)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)

  • #2
    Check exact locations of the loaded spring libraries. I assume that they are loaded from the shared tomcat libraries and can't see log4j binaries then. You can check that via adding -verbose JVM option, it shows exact code sources for the loaded classes.

    Comment


    • #3
      not sucess

      Originally posted by denis.zhdanov View Post
      Check exact locations of the loaded spring libraries. I assume that they are loaded from the shared tomcat libraries and can't see log4j binaries then. You can check that via adding -verbose JVM option, it shows exact code sources for the loaded classes.
      Thanks for reply I learned new think I have tried the -verbose:class JVM option

      I can see [Loaded org.springframework.beans.factory.support.BeanDefi nitionReaderUtils from file:/C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/spring/WEB-INF/lib/spring-beans.jar]
      [Loaded org.springframework.beans.factory.support.GenericB eanDefinition from file:/C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/spring/WEB-INF/lib/spring-beans.jar]

      But there is no line about loaded LogManager I have tried to put a Jar into all folders where others classes were loaded but no result. Any other ideas?

      Comment


      • #4
        Originally posted by prcek View Post
        I can see [Loaded org.springframework.beans.factory.support.BeanDefi nitionReaderUtils from file:/C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/spring/WEB-INF/lib/spring-beans.jar]
        [Loaded org.springframework.beans.factory.support.GenericB eanDefinition from file:/C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/spring/WEB-INF/lib/spring-beans.jar]

        But there is no line about loaded LogManager I have tried to put a Jar into all folders where others classes were loaded but no result. Any other ideas?
        I analyzed the stacktrace a bit - there is the following class:

        org.springframework.web.util.Log4jConfigListener
        Bootstrap listener for custom log4j initialization in a web environment. Delegates to Log4jWebConfigurer (see its javadoc for configuration details). WARNING: Assumes an expanded WAR file, both for loading the configuration file and for writing the log files. If you want to keep your WAR unexpanded or don't need application-specific log files within the WAR directory, don't use log4j setup within the application (thus, don't use Log4jConfigListener or Log4jConfigServlet). Instead, use a global, VM-wide log4j setup (for example, in JBoss) or JDK 1.4's java.util.logging (which is global too).

        Comment

        Working...
        X