users@glassfish.java.net

Re: Classloader Hierarchy in Glassfish using deployed Resource adapters

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Tue, 24 Jan 2012 05:54:38 +0530

On Monday 23 January 2012 06:24 PM, Gustavo Henrique Orair wrote:
> I'm having problems with classloading when using Glassfish ResourceAdapters.
> By deploying rar, their libraries seem to take precedence to both
> Glassfish libraries and application libraries itself.
This is not expected.
> When deploying jackrabbit JCA with global classloading , this resulted
> in a conflict in the ejb-timer-service that used the derby library
> because there was a different derby version inside the jackrabbit.rar.
Should not have happened. Do you have Derby jars in glassfish3/javadb/lib/?

Can you give us a test case to this effect?
> In addition, my application uses the Logback and has the file
> logback.xml with the settings of the Logging system. But it seems that
> the classloader system first the logback.xml inside a library jar
> (jackrabbit-jca.jar) within the resource adapter jackrabbit-jca.rar.
> So, it used the logback.xml shipped within jackrabbit-jca.rar instead
> of my own configuration.
>
Application classloader searches in rar class loader first, so this can
happen.
> I would like to understand better the priority rules of loading when
> using Resource Adapters.
>
Just look for classloader hierarchy in GlassFish documents.
> This problem results in several other classloading problems such as
> commons-io inside the jackrabbit-jca.rar is at version 1.4 and my
> application uses version 2.0.1.
>
> Is there any way to "isolate" the Rar libraries for use only in
> classes inside this rar? What's the best approach to avoid all these
> conflicts?
>
No, not unless you take complete control of your application class
loading by turning it into an OSGi bundle. If you are interested, take a
look at http://glassfish.java.net/public/GF-OSGi-Features.pdf

Sahoo
> If anyone has faced these problems in a similar environment, what is
> the recommended way to configure this environment?
>
> ---------------------------------------------------------------------------------------------------------------------
> Gustavo Henrique Orair
> ------------------------------------------------------------------------------------------------------------------