« Return to Thread: Classpath Issues with Log4J?

Re: Classpath Issues with Log4J?

by Matt Wringe :: Rate this Message:

Reply to Author | View in Thread


On Tue, 2009-02-24 at 22:09 +0000, Adrian Cole wrote:
> I'm guessing commons-logging is in a parent classloader and can't
> resolve log4j.
OK, he is using the embedded Jetty container in which Cargo
automatically adds a commons-logging jar but not a log4j jar.

It looks like its the Cargo embedded Jetty dependency autoresolver that
bites us again :(
see org.codehaus.cargo.maven2.jetty.JettyArtifactResolver

That really needs to be fixed to allow people to specify the classpath
if needed.

> Can you dump your classpath?
>
> Cheers,
> -Adrian
>
> On Tue, Feb 24, 2009 at 9:38 PM, David C. Hicks <dhicks@...>
> wrote:
>        
>        
>         Matt Wringe wrote:
>                 Ok, the data provided does really help me.
>                 Jetty doesn't contain a log4j file and cargo doesn't
>                 reference any
>                 org.apache.log4j classes. I am guessing the webapp
>                 contains the log4j
>                 jar within its web-inf/lib directory and the webapp
>                 tries to reference
>                 log4j and the error gets thrown? Any more data you can
>                 provide?
>                  
>         Absolutely!  I'll be more than happy to give you tons of
>         information.  I just didn't want to flood the list,
>         initially.  :-)
>        
>         Yes, the log4j jar is in WEB-INF/lib.  It is version 1.2.14.
>          It appears to me that the exception is thrown by Jetty as it
>         begins the process of initializing the web context for the
>         embedded application.  (I am trying to run this in embedded
>         mode.)  A larger chunk of the exception stack is included
>         below.  One of the first things that happens when the context
>         initializes (in our app) is that we initialize logging the way
>         we want it to work.  However, I don't see that class/method in
>         this stack.  So, I'm not sure if we've even gotten that far
>         along, yet.
>        
>         If I can provide anything else, please just let me know.  It
>         might take a bit of time - I'm working on other things, right
>         now, so have to recreate the environment that causes this
>         exception.  It's easy to create, though, and I don't mind
>         helping track down a problem, if I can.
>        
>         Dave
>        
>         2009-02-24 16:27:52.098::INFO:  Extract
>         jar:file:/home/dhicks/workspace/salient/war/target/salient-war-0.1.40-SNAPSHOT.war!/ to /tmp/Jetty_0_0_0_0_8080_salient-war-0.1.40-SNAPSHOT.war__salient-war-0_1_40-SNAPSHOT__u13vah/webapp
>         2009-02-24 16:27:53.727::WARN:  failed
>         org.mortbay.jetty.webapp.WebAppContext@48bc64{/salient-war-0.1.40-SNAPSHOT,jar:file:/home/dhicks/workspace/salient/war/target/salient-war-0.1.40-SNAPSHOT.war!/}
>         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.webapp.WebXmlConfiguration.newListenerInstance(WebXmlConfiguration.java:644)
>               at
>         org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:625)
>               at
>         org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:366)
>               at
>         org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:288)
>               at
>         org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:221)
>               at
>         org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:179)
>               at
>         org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1188)
>               at
>         org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:481)
>               at
>         org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:434)
>               at
>         org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>               at
>         org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
>               at
>         org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:120)
>               at
>         org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>               at
>         org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
>               at
>         org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>               at
>         org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
>               at org.mortbay.jetty.Server.doStart(Server.java:210)
>               at
>         org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>               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.codehaus.cargo.container.jetty.internal.JettyExecutorThread.run(JettyExecutorThread.java:68)
>         Caused by:
>         org.apache.commons.logging.LogConfigurationException:
>         org.apache.commons.logging.LogConfigurationException: No
>         suitable Log constructor [Ljava.lang.Class;@18b9a72 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;@18b9a72 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.tiles.web.startup.TilesListener.<clinit>(TilesListener.java:45)
>               ... 29 more
>         Caused by:
>         org.apache.commons.logging.LogConfigurationException: No
>         suitable Log constructor [Ljava.lang.Class;@18b9a72 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)
>               ... 33 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)
>               ... 34 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:306)
>               at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>               at
>         java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>               ... 39 more
>        
>        
>        
>        
>         ---------------------------------------------------------------------
>         To unsubscribe from this list, please visit:
>        
>           http://xircles.codehaus.org/manage_email
>        
>        
>        
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Classpath Issues with Log4J?