users@glassfish.java.net

Glassfish classloaders

From: <glassfish_at_javadesktop.org>
Date: Thu, 21 Feb 2008 21:05:04 PST

I'm having an issue with the Glassfish Classloaders.

I'm using the Stripes web framework. One of the things that it does is on startup, it will crawl through classes looking to map URLs to action classes.

I have 2 WARs deployed within a single EAR.

Each WAR has their own copy of the stripes.jar file (it bundled within WEB-INF/lib of each respective WAR).

However, I have 2 classes, one in each WAR, that happen to map to the same URL.

When I hit the URL in WAR A, it's actually calling the class from WAR B.

I'm curious how WAR A can see ANY classes from WAR B.

I can imagine if the stripes.jar was a common library, bundled within the EAR itself vs the individual WARs, then the two WARs might well share the same stripes.jar (and therefore any singletons it may be using).

But shouldn't the two WARs be isolated from each other?

Looking around, I saw this line from https://glassfish.dev.java.net/nonav/javaee5/docs/DG/beade.html

Specifically these two lines:

Application Universe: Each Java EE application has its own class loader universe, which loads the classes in all the modules in the application.

Individually Deployed Module Universe: Each individually deployed EJB JAR, web WAR, or lifecycle module has its own class loader universe, which loads the classes in the module.

Are these mutually exclusive? Under the Application Universe, are ALL of the classes within the EAR in a single, common classloader soup? Or is there a common Application Universe AS WELL as separate module Universes within the application? The diagram earlier in the document suggest a hierarchy.

Any thoughts appreciated.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=260368