Let me try to explain the scenario that I am seeing that makes me think there is some sort of linkage/inheritance of class loaders going on between embedded and the wep-applications. This following example illustrates the issue, though I have worked around it for now but I think points out a bigger concern.
Common.jar: ClassA, ClassB (Only ClassB references ClassL from License.jar)
MyServerApp --> includes Common.jar in classpath --> references ClassA
WebApp1 --> includes Common.jar and License.jar --> references ClassA and ClassB
When I try to deploy and run WebApp1 I will get exceptions complaining about not being able to find ClassL,
but if I add License.jar to the classpath for MyServerApp everyone is happy.
This looks to me like the ClassLoad for WebApp1 is inheriting the classpath or classes from the original ClassLoader used by MyServerApp.
So:
Ignoring the strange dependency on ClassL; my concern is that if I have MyServerApp, WebApp1, WebApp2, etc. all referencing Common.jar that only the copy of it pointed to by the original classpath of MyServerApp will be loaded. So, if I deploy say WebApp3 which now uses a newer version of Common.jar that it will never be able to utilize it since it will be essentially preempted by the first one found in the MyServerApp classpath.
Assumptions in this example:
None of the apps communicate with each other so differences in the Common.jar copies between them are okay since they are just utility classes
Each webApp's WAR file contains its own copy of Common.jar
We do not want all the apps using the same Common.jar - makes it harder for incremental hotfixes in the field for us if they do - and if we did we would just put them in a common location such as <install_dir>domain/lib/
Did any of the above make any sense? Basically what I am looking for is isolation between the ClassLoaders of the main server app and the web-apps that it deploys, and between web-apps of course.
JBoss has a switch to create this sort of isolation:
http://www.jboss.org/community/docs/DOC-9288
________________________________
From: Byron.Nevins_at_Sun.COM [mailto:Byron.Nevins_at_Sun.COM]
Sent: Tuesday, April 28, 2009 2:31 PM
To: embedded_at_glassfish.dev.java.net
Cc: Jennifer.Chou_at_Sun.COM; Siraj Ghaffar; Jan Luehe
Subject: Re: [embedded] RE: [Fwd: Re: Problem running Embedded Glassfish on Linux]
ClassLoaders in Embedded:
We just use the plain old super simple System Classloader. The web container does its own fancy complicated class loading stuff which is completely independent of embedded vs. non-embedded.
AFAIK you should never have to put a jar that is already inside a deployed war into the System Classloader. You don't have more than one web app accessing the jar - right? You aren't accessing any classes from the jar "outside" of the webapp - right?
Jan - do you have any ideas about this?
Sorry to badger you (Jan) again but you are the Guru in this area!
Joey Jarosz wrote:
Hi gang,
It turns out that a combination of typos and JDK installation issues were at the root of this problem. I already updated the bug report accordingly. Sorry for the fire drill.
I do have a question however how class paths are handled in Embedded. I have a particular WebApp that depends on another JAR file. That JAR file is indeed in the WAR file in the WEB-INF/lib directory. But if I do not include the same JAR file on the classpath used to start my java application (that starts the server) I get a NoClassDefFoundError exception.
I am assuming there is something about how the ClassLoaders work in Embedded Glassfish.
-----Original Message-----
From: Jennifer.Chou_at_Sun.COM [mailto:Jennifer.Chou_at_Sun.COM]
Sent: Monday, April 20, 2009 1:39 PM
To: Siraj Ghaffar
Cc: Joey Jarosz
Subject: Re: [Fwd: Re: Problem running Embedded Glassfish on Linux]
To clarify....are we using the embedded-glassfish project issue list?
https://embedded-glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT
or the glassfish project issue list
https://glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT
We would need to add an embedded subcomponent.
Jennifer
Siraj Ghaffar wrote:
Hi Joey,
Please file a bug on the v3 trunk for this issue.
Thanks
--Siraj
Jennifer Chou wrote:
------------------------------------------------------------------------
Subject:
RE: Problem running Embedded Glassfish on Linux
From:
Joey Jarosz <joey_at_cadence.com> <mailto:joey_at_cadence.com>
Date:
Mon, 20 Apr 2009 13:02:27 -0700
To:
Jennifer.Chou_at_Sun.COM
To:
Jennifer.Chou_at_Sun.COM
Hi Jennifer, thanks for getting back to me.
Are there "embedded" builds based on the v3 main trunk where
development is now taking place?
If I do not end up with a solution, I will definitely find a bug -
same buglist as usual?
------------------------------------------------------------------------
*From:* Jennifer.Chou_at_Sun.COM [mailto:Jennifer.Chou_at_Sun.COM]
*Sent:* Monday, April 20, 2009 11:08 AM
*To:* Joey Jarosz
*Subject:* Re: Problem running Embedded Glassfish on Linux
Hi Joey,
Sorry about that - the alias is still valid. I've been focused on
deliverables for a milestone for non-embedded GlassFish and have been
a little out-of-the loop on embedded. I believe we've made progress
on moving embedded from the embedded prelude branch over to the same
workspace as regular v3 main trunk development. So all bugs will be
fixed there - and it sounds like you have found a bug. You may want
to file a bug.
I'll be off for the next couple days - I'll see if somebody can take
a look.
Jennifer
Joey Jarosz wrote:
Hi Jennifer,
I have not heard anything from the mailinglist regarding my problem
and since I usually get a pretty quick response to my queries I
wonder if maybe the email alias has changed again or something.
Anyway, I am dead in the water with this problem. I cannot
realistically go back to the b07 build as I have too much code
dependent on the api changes up to the b14 build.
Do you have any clues as to why this is happening?
I have even tried not deploying any web apps but I still get the same
basic problem of the ZipException when trying to open some jar file
(which one is a mystery). I have tried it on two different linux
boxes including the one that I have a b07 based early version of my
application working.
-------------------------------
Hi all,
I decided to copy over my application over to Linux for some testing.
I've done it a while ago (I think it was on build b07) but figured it
would easy to get my latest up and running. Oops!
Both Windows and Linux_x86 computers are running the same version of
JDK (jdk1.6._13) and embedded GF build b14.
I've attached most of the traceback starting just before the first
SEVERE level message. I've checked file permissions across the board,
no problem. My two application WAR files get expanded just fine in to
the glassfish "applications" directory.
Has anyone a clue of what might be the problem? I hesitate to just
grab a newer build because in the past that has meant me having to
modify my code again and again to keep up with the fast changing API
- but if someone can confirm that this sort of problem is fixed in a
newer build I guess I will bite the bullet.
joey
------------------------------------------------------
ArchiveFactory factory =
server.getHabitat().getComponent(ArchiveFactory.class);
ApplicationLifecycle lifecycle =
server.getHabitat().getComponent(ApplicationLifecycle.class);
EmbeddedFileSystem efs = server.getFileSystem();
ReadableArchive a = factory.openArchive(app);
ArchiveHandler h = lifecycle.getArchiveHandler(a);
File appDir = new File(efs.getApplicationsDir(), a.getName());
FileUtils.whack(appDir);
appDir.mkdirs();
h.expand(a, factory.createArchive(appDir));
a.close();
return factory.openArchive(appDir); <<<ß----- probably appears to
start here.
------------------------------------------------------
INFO: Embedded GlassFish Prelude v3 Prelude startup time :
Embedded(203ms) startup services(436ms) total(639ms)
Apr 17, 2009 3:17:35 PM com.sun.enterprise.web.WebContainer
createHttpListener
INFO: Created HTTP listener http-listener-1 on port 8888
Apr 17, 2009 3:17:35 PM com.sun.enterprise.web.WebContainer
createHttpListener
INFO: Created HTTP listener http-listener-2 on port 8282
Apr 17, 2009 3:17:35 PM com.sun.enterprise.web.WebContainer createHosts
INFO: Created virtual server vserver-apps
Apr 17, 2009 3:17:35 PM com.sun.enterprise.web.WebContainer createHosts
INFO: Created virtual server vserver-secure
Apr 17, 2009 3:17:35 PM org.apache.commons.modeler.Registry
registerComponent
SEVERE: Null component
com.sun.appserv:type=JspMonitor,name=jsp,WebModule=//vserver-secure/,J2EEApplication=null,J2EEServer=server
Apr 17, 2009 3:17:35 PM org.apache.catalina.core.ContainerBase
startChildren
SEVERE: PWC1240: Container
StandardEngine[com.sun.appserv].StandardHost[vserver-
secure].StandardContext[] has not been started
java.lang.RuntimeException: java.util.zip.ZipException: error in
opening zip file
at
com.sun.enterprise.util.net.JarURIPattern.getJarEntries(JarURIPattern.java:83)
at
org.glassfish.faces.integration.GlassFishTldProvider.postConstruct(GlassFishTldProvider.java:122)
at
com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
at
com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at
com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at org.jvnet.hk2.component.Habitat$1.get(Habitat.java:252)
at java.util.AbstractList$Itr.next(AbstractList.java:345)
at
com.sun.enterprise.web.WebModuleListener.configureJsp(WebModuleListener.java:257)
at
com.sun.enterprise.web.WebModuleListener.lifecycleEvent(WebModuleListener.java:147)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:159)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5315)
at com.sun.enterprise.web.WebModule.start(WebModule.java:456)
at
org.apache.catalina.core.ContainerBase.startChildren(ContainerBase.java:1514)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1180)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:977)
at
org.apache.catalina.core.ContainerBase.startChildren(ContainerBase.java:1514)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1180)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:550)
at org.apache.catalina.startup.Embedded.start(Embedded.java:945)
at
com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:630)
at
com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
at
com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at
com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at org.jvnet.hk2.component.Habitat.getBy(Habitat.java:567)
at org.jvnet.hk2.component.Habitat.getByType(Habitat.java:548)
at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:317)
at org.glassfish.embed.Server.start(Server.java:321)
at com.chipestimate.server.AppServer.start(AppServer.java:108)
at com.chipestimate.server.CCPSServer.startAppServer(CCPSServer.java:71)
at com.chipestimate.server.CCPSServer.main(CCPSServer.java:420)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.zerog.lax.LAX.launch(DashoA10*..)
at com.zerog.lax.LAX.main(DashoA10*..)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:133)
at java.util.jar.JarFile.<init>(JarFile.java:97)
at
com.sun.enterprise.util.net.JarURIPattern.getJarEntries(JarURIPattern.java:73)
... 45 more
Apr 17, 2009 3:17:35 PM org.apache.commons.modeler.Registry
registerComponent
SEVERE: Null component
com.sun.appserv:type=JspMonitor,name=jsp,WebModule=//vserver-apps/,J2EEApplication=null,J2EEServer=server
Apr 17, 2009 3:17:35 PM org.apache.catalina.core.ContainerBase
startChildren
SEVERE: PWC1240: Container
StandardEngine[com.sun.appserv].StandardHost[vserver-apps].StandardContext[]
has not been started
java.lang.RuntimeException: java.util.zip.ZipException: error in
opening zip file
at
com.sun.enterprise.util.net.JarURIPattern.getJarEntries(JarURIPattern.java:83)
at
org.glassfish.faces.integration.GlassFishTldProvider.postConstruct(GlassFishTldProvider.java:122)
at
com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java
:87)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
at
com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at
com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
at org.jvnet.hk2.component.Habitat$1.get(Habitat.java:252)
at java.util.AbstractList$Itr.next(AbstractList.java:345)
at
com.sun.enterprise.web.WebModuleListener.configureJsp(WebModuleListener.java:257)
at
com.sun.enterprise.web.WebModuleListener.lifecycleEvent(WebModuleListener.java:147)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:159)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5315)
at com.sun.enterprise.web.WebModule.start(WebModule.java:456)
at
org.apache.catalina.core.ContainerBase.startChildren(ContainerBase.java:1514)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1180)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:977)
at
org.apache.catalina.core.ContainerBase.startChildren(ContainerBase.java:1514)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1180)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:550)
at org.apache.catalina.startup.Embedded.start(Embedded.java:945)
at
com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:630)
at
com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
at
com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
at
com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
--------------------------------------------
Joey Jarosz
Senior Architect
//Chip Planning Solutions//
**/Cadence Design Systems, Inc./***/
/*(408) 914-6269
/*/Need some IP? Check out /*//*/www.chipestimate.com/*/
<
http://www.chipestimate.com> <
http://www.chipestimate.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: embedded-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: embedded-help_at_glassfish.dev.java.net
--
Byron Nevins Work 408-276-4089, Home 650-359-1290, Cell 650-784-4123 - Sun Microsystems, Inc.