« Return to Thread: Issue stopping Resin 3.0.23 with Cargo

RE: NoClassDefFoundError when using embedded jetty6x

by Marwan.Zeineddine :: Rate this Message:

Reply to Author | View in Thread

Hi,

If I may bud in. And it's fairly speculative in that I'm in a hurry but
thought that this might help even though I'm not 100% sure of it.

If we go back to the classloaders hierarchy, if the parent classloader has
loaded log4j already, then by default it will be consulted first when a
class is needed by the component/bottom-classloader.

Loading log4j in a child classloader doesn't help as it will be bypassed
to go straight to its parent, and loading the dependency commons-logging
class/jar in the child classloader won't help either because they're not
visible from the parent classloader and you get a NoClassDefFounError.

So either make sure only the child classloader loads both log4j and
commons-logging, or you'll need to load commons-logging and log4j using
the parent classloader. In practice this means bundling the jars in the
ejb module not the war.

Marwan


-----Original Message-----
From: dmccarthy@... [mailto:dmccarthy@...]
Sent: 23 February 2007 14:57
To: user@...
Subject: Re: [cargo-user] NoClassDefFoundError when using embedded jetty6x

I'm afraid that doesn't make any difference Ronald - the same
NoClassDefFoundError is thrown even if I add commons-logging as a
dependency. You could be onto something when you say it's a classloader
issue though, as there is definitely *some* log4j jar loaded (it's in
the war file, and it lists it in the debug messages when I run maven
with the -X flag).

Life is hard, and then you die wrote:
> On Fri, Feb 23, 2007 at 12:37:45PM +0000, Denis McCarthy wrote:
>>>> I'm trying to use the cargo-maven2-plugin with jetty (embedded). When
I
>>>> try to start my container (I'm starting it as part of my integration
>>>> test phase, to run selenium tests) I'm getting a noclassdeffounderror
on

>>>> log4j. Here's part of the trace:
>>>>
>>>> No suitable Log constructor [Ljava.lang.Class;@9db992 for
>>>> org.apache.commons.logging.impl.Log4JLogger (Caused by
>>>> java.lang.NoClassDefFoundError: org/apache/log4j/Category))
>>>>
>>>> As you can see, commons-logging seems to be picked up alright, so at
>>>> least some dependencies seem to be available to jetty.
>>>>
>>>>
>>>> Here's the appropriate section of the config in my pom:
>>>>
>>>> <plugin>
>>>>  <groupId>org.codehaus.cargo</groupId>
>>>>  <artifactId>cargo-maven2-plugin</artifactId>
>>>>  <configuration>
>>>>  <wait>false</wait>
>>>>  <container>
>>>>    <containerId>jetty6x</containerId>
>>>>    <type>embedded</type>
>>>>    <dependencies>
>>>>      <dependency>
>>>>        <groupId>log4j</groupId>
>>>>        <artifactId>log4j</artifactId>
>>>>        <location>
>>>> /home/dmccarthy/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar
>>>>    </location>
>>>>        </dependency>
>>>>      </dependencies>                  
>>>>    </container>
>>>>  <configuration>
>
> This looks like the usual classloader problem that is so common with
> commons-logging. Try ensuring commons-logging is loaded the same
> classloader as log4j by specifying it as a dependency too:
>
>         <dependencies>
>           <dependency>
>             <groupId>log4j</groupId>
>             <artifactId>log4j</artifactId>
>             <version>1.2.14</version>
>           </dependency>
>           <dependency>
>             <groupId>commons-logging</groupId>
>             <artifactId>commons-logging</artifactId>
>             <version>1.1</version>
>           </dependency>
>         </dependencies>                  
>
>
>   Cheers,
>
>   Ronald
>
>
> ---------------------------------------------------------------------
> 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


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

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Issue stopping Resin 3.0.23 with Cargo