users@glassfish.java.net

GlassFish V2.1.1 to V3 migration - JCA ClassLoader problem

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Jun 2010 08:40:39 PDT

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