The Java EE spec does *not* mandate class loading isolation among
modules of a single ear. The behavior can be different from one
appserver to another. So, if you want to be portable, then don't rely on
any specific behavior of any appsever.
If you want GlassFish to load two copies of the class from two different
wars, then try using "class loading delegation feature" in sun-web.xml.
The attribute is defined like this in sun-web...dtd:
delegate If set to false, the delegation behavior
of the web application's classloader complies
with the Servlet 2.3 specification,
section 9.7.2, and gives preference to classes
and resources within the WAR file or the
extra-class-path over those higher up in the
classloader hierarchy, unless those classes or
resources are part of the Java EE platform.
If set to its default value of true, classes
and resources residing in container-wide
library
JAR files are loaded in preference to classes
and resources packaged within the WAR file or
specified on the extra-class-path.
Thanks,
Sahoo
glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>