users@jersey.java.net

Re: [Jersey] Classloader Issues

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 14 Dec 2009 14:14:21 +0100

Hi Cemo,

You can set class loader delegation to false, since the JAX-RS API
will not change. You might see some exceptions being thrown by Jersey
but it will not stop the application running.

The reason for the exceptions are because setting class loader
delegation to false does not fully isolate the dependencies,
especially related to those declared in META-INF/services e.g. Jersey
1.1.5-ea-SNAPSHOT deployed in the war will also load Jersey 1.1.4.1
components declared in META-INF/services. This is unfortunate but
there is nothing i can do about that until GlassFish fully supports a
better isolation mechanism (it nearly does via OSGi but we did not
have time to implement this for the v3 release).

A reasonable solution would be to enable the installation of the IPS
packages that we continuously build but for some reason (perhaps
because of the age of aquarius???) IPS packages can only be currently
installed if they are hosted on a server.



> 1 ) What is the best way to use firstly bundled libraries without
> regarding
> their package name and other things.
>

Unfortunately there is no "best way" for wars. You need something like
OSGi or Java modules.

>
> 2 ) What is the motivation behind delegation classloading to
> container? In
> my opinion, classloading should be default false because if a
> library is
> included to an application, it should be loaded firstly... At least I
> believe so :)

I do not know the rational as to why by default classloader delegation
is set to true, it might be a spec requirement.

IMHO the class loader delegation feature is a hack because Java does
not (yet!) have a module system, although GlassFish does and we be
able, as i previously said, it avail of that.

Paul.


On Dec 14, 2009, at 1:59 PM, Cemo Koc wrote:

>
> Hi,
>
> I have a question about Jersey and final Glassfish V3. This version
> is using
> Jersey: 1.1.4.1 and at logs I can see Jersey related logs such as :
>
> [#|2009-12-11T18:52:23.142+0200|INFO|glassfishv3.0|
> com.sun.jersey.server.impl.application.WebApplicationImpl|
> _ThreadID=29;_ThreadName=Thread-1;|Initiating
> Jersey application, version 'Jersey: 1.1.4.1 11/24/2009 01:37 AM'|#]
>
>
> However I want to use latest Snapshot of Jersey with my war
> application.
> However I can not see necessary logs after deployment of my
> application
> about Jersey 1.1.5-ea-SNAPSHOT.
>
> First of all, I tried to change delegation model in my application
> like
>
> <class-loader>
> <property name="delagate" value="false"/>
> </class-loader>
>
> However this try could be successful. Then I dig little then I found
> liI am
> not sure about this but I found such a comment in glassfish forum:
>
> The webapp classloader ignores the delegate flag for a number of
> packages,
> including any packages starting with javax.* and
> org.apache.taglibs.standard.*, and will unconditionally delegate
> resolution
> of any symbols in these packages to the parent classloader.
>
> http://forums.java.net/jive/message.jspa?messageID=359220
>
> I know that this is not only related to Jersey. I am not eager to
> delete any
> library from glassfish installation folder.
>
> 1 ) What is the best way to use firstly bundled libraries without
> regarding
> their package name and other things.
>
>
> 2 ) What is the motivation behind delegation classloading to
> container? In
> my opinion, classloading should be default false because if a
> library is
> included to an application, it should be loaded firstly... At least I
> believe so :)
>
>
> Thanks
> --
> View this message in context: http://n2.nabble.com/Classloader-Issues-tp4163936p4163936.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>