Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    problems with log4j

    Hi there,

    There is a weird problem I keep bumping into:

    Even if there is a log4j JAR file in war/WEB-INF/lib, the classes from it are not found! If I unzip the jar, and add the folder to the classpath, everything works fine.

    I have seen this with GWT 1.7.1, GWT 2, SmartGwt-EE 1.2.1 Evaluation version, SmarGwt-Pro 1.2.1, SmartGwt-Pro 2.0.

    The config file for logging is in place, and I have not modified it. The error message looks like this:

    Starting Jetty on port 8888
    [WARN] failed jsp
    java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:253)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:447)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:536)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:377)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:938)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:690)
    at com.google.gwt.dev.DevMode.main(DevMode.java:251)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@16be68f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@16be68f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.jasper.servlet.JspServlet.<clinit>(JspServlet.java:58)
    ... 27 more
    Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@16be68f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    ... 31 more
    Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.getConstructor(Class.java:1657)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
    ... 32 more
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    ... 37 more

    --------------------------

    The class which is not found (org.apache.log4j.Category) exists in the log4j jar file, and if I extrect the JAR, and add the contents to the classpath, it is found all right.

    Has anyone seen this? I can work around this, but it's annoying...

    #2
    Forgot to mention: this occurs in GWT hosted mode and dev mode (with Jetty). When actually deploying the app as a war file, it works OK.

    Comment


      #3
      For the record: adding the log4j file to my app's build path solved the problem.

      (Note this this should not be necessary, since server-side libraries should be found automatically from JAR files in WEB-INF/lib, and they usually are, just the log4j library was behaving funny. Still don't understand way, but whatever.)

      Comment

      Working...
      X