Class loading and Scoping issue with multiple wars outside of ear
7rond Oct 1, 2008 7:56 PMHello
I've run into some issues here that I'm not quite sure I am going to go about figuring out. I'm working with implementing a CMS based on the Seam framework and so far it has been going great - but this issue with class loading is bothering me.
First, how we're building and deploying our applications. The thought behind this is that we want the framework of the CMS to be deployed in a EAR on the server, and we want the web applications built on the CMS to be deployed as single, standalone WARs for easy and quick deployments. I've structured the problem a little something like this;
- cms-framework.ear - this contains all the framework code for the CMS, including JPA entities, seam home implementations, seam query implementations and other CMS-specific code
cms-admin.war - this contains the administration tool webapp for the CMS, it uses mostly code from cms-framework.ear, but it has some custom code, namely a overidden Identity class, defined as such (and deployed into WEB-INF/classes/ of this project):
@Name("org.jboss.seam.security.identity") @Scope(ScopeType.SESSION) @Install(precedence = Install.DEPLOYMENT) @BypassInterceptors @Startup public class AdminIdentity extends Identity { }
cms-testsite.war - this contains a simple site implementation based on the code in cms-framework.ear.
I don't bundle any dependencies with my app, such as Seam and other dependent projects, all those dependencies are deployed into server/default/lib/ on my JBoss instance (4.2.3.GA)
Now, about the actual problem. If I, inside my cms-testsite, for instance try to get a instance of the current Identity using either this in a Java file;
@In private Identity identity
..or this in a JSF template;
#{identity}
I get a instance of the AdminIdentity class that's only deployed within the cms-admin.war. I've been going through the log data from the Seam initialization phase for both webapps, and I can clearly see that the overriden AdminIdentity is -not- loaded for the cms-testsite, but it is for the cms-admin.
Now, my impression of this was that each webapp is supposed to be completely isolated. I have the following in the jboss-web.xml on both webapps;
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd"> <jboss-web> <class-loading java2ClassLoadingCompliance="false"> <loader-repository> my.org:loader=<site id> <loader-repository-config>java2ParentDelegation=false</loader-repository-config> </loader-repository> </class-loading> <depends>jboss.j2ee:service=EARDeployment,url='cms-framework.ear'</depends> </jboss-web>
I have no loader-repository defined in jboss-app.xml inside the EAR as that seems to break everything with the webapps not being able to read the classes inside the EAR.
I'm not very familiar with how class loading internally works, and forgive me if I've made some apparent mistakes here, but I cannot understand why this is behaving the way it is. I've tested this on multiple versions of Seam, both 2.0.2, 2.0.3 and the new 2.1.0.CR1 and they all behave somewhat the same way.
Will this way of bundling the project not work with Seam? Or am I doing anything wrong? I'm going to try to reproduce this by writing a small sample of the projects and uploading somewhere for people to see if they wish, I just wanted to post here beforehand to perhaps get some input on some mistakes I may have made that's leading to this.