users@glassfish.java.net

Re: GlassFish 3.1 Classloader Question

From: Hong Zhang <hong.hz.zhang_at_oracle.com>
Date: Mon, 06 Jun 2011 12:25:40 -0400

Hi, Chris
    While the classes in the war libraries are guaranteed to be visible
to the war classes, the reverse is not guaranteed. If you want certain
class to be visible to the library jar, you need to use Manifest
Class-Path entry to reference the enclosing jar for that class. The
reason that when you put the class in another library jar and worked
probably because the war library jars are loaded by the same classloader.

- Hong

On 6/6/2011 11:34 AM, forums_at_java.net wrote:
> Hi all,
>
> I'm in the process of upgrading an old project from Glassfish 2.1 to
> 3.1. I
> ran into a somewhat puzzling problem that I wondered if anyone could shed
> some light on.
>
> Some details:
>
> * I'm packaging my app as a "Enterprise Application Project"
> * in NetBeans (7.0) and
> * deploying the EAR to GlassFish 3.1 (build 43).
> * My app consists of:
> * * an EJB jar
> * a WAR
> * With several jar libraries
>
>
>
> One of the jar libraries does some initialization using reflection and
> calls
> "class.forName(...)" to try to load a class and set up some services.
>
> When this class is inside the WAR itself (where it was originally), I was
> get "NoClassDefFound" (or ClassNotFoundException, I forget which).
>
> When I moved the class out into a separate jar library (alongside the jar
> that tries to load it) it works fine.
>
> What's going on here? Is this by design?
>
> Thanks for any light you can shed.
>
> --Chris
>
>
> --
>
> [Message sent by forum member 'christopherrued']
>
> View Post: http://forums.java.net/node/809783
>
>