users@glassfish.java.net

Re: GlassFish V2.1.1 to V3 migration - JCA ClassLoader problem

From: Sanjeeb Sahoo <sahoo_at_sun.com>
Date: Thu, 03 Jun 2010 21:39:50 +0530

On Thursday 03 June 2010 09:10 PM, glassfish_at_javadesktop.org wrote:
> Hi,
>
> I'm working on migrating an application from GlassFish V2.1.1 to GlassFish V3.0. The migration has not succeeded yet because of a peculiar change of behavior.
>
> A year ago I posted a thread [1] on this forum about JCA resource adapter class loaders being shared with all deployed applications. My JCA connector uses some libraries that are also used by web applications. When a web application tries to bundle a newer version of the library in its .war, the older version of the class from the JCA connector is used instead. Also, my web application can use classes in the JCA connector without including the JCA connector classes in the .war. In Maven I use the "provided" scope to describe the dependency on the JCA connector.
>
> Sahoo responded with the following information:
>
>
>> Yes, this is by design and spec compliant. Resource Adapters are
>> considered like system libraries and hence they are shared by all other
>> applications. Section EE.8.4 of Java EE 5 spec says the following:
>>
>> "Standalone resource adapters delivered in .rar files and standalone
>> class libraries delivered in .jar files that become installed libraries
>> will of necessity appear in the class namespaces of applications that
>> use them, and may appear in the class namespace of any application
>> depending on the level of isolation supported by the Java EE product."
>>
> My JCA connector is deployed as a standalone .rar file. It is not part of an EAR.
>
> To get around the problem, I release a new build of the JCA connector using the new version of the library.
>
> Now that I am upgrading to GlassFish V3, there is a new problem. My deployed web application gets ClassNotFoundException when trying to use the classes in the JCA connector. I don't think GlassFish V3 makes all classes in all deployed JCA connectors visible to all other deployed applications like GlassFish 2.1 used to.
>
> So, I changed the depency scope from "provided" to "compile" in my Maven pom.xml and tried again. Now when my web app tries to use the JCA connector, it gets the following error:
>
> com.ijws.cicokioskcl.ra.cci.CicoKioskConnectionFactory cannot be cast to com.ijws.cicokioskcl.ra.cci.CicoKioskConnectionFactory
>
>
> Can someone please explain to me how this particular feature in GlassFish has changed, why it changed, if this change is now clearly specified in Java EE 6, and what I can do to work around the problem?
>
>
> Thanks,
> Ryan
>
> [1] http://forums.java.net/jive/thread.jspa?messageID=347049&#347049
> [Message sent by forum member 'rdelaplante']
>
> http://forums.java.net/jive/thread.jspa?messageID=472602
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
Hi Ryan,

RAR class visibility has changed in EE6. It now requires an application
server to provide an isolation level by default such that classes from
only those standalone RARs that are used by an application are visible
to the application. You can consult the EE6 platform spec for further
details. GlassFish v3 and beyond follows this new rule. I don't know if
GlassFish exposes an option to switch to the old class loading policies
for standalone RARs.

Coming to the ClassCastException, are you using delegate=false? If not,
can you describe how

com.ijws.cicokioskcl.ra.cci.CicoKioskConnectionFactory.class

is made available to RAR and WAR so that we can analyse how two copies
of it are getting loaded causing CCE.

Thanks,
Sahoo