wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Two WAR files that have common jars to one EAR - Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply locked New topic
Author

Two WAR files that have common jars to one EAR - Issue

Ramu Nur
Greenhorn

Joined: Aug 21, 2010
Posts: 22
Hi
We have to create an EAR file that should have two WAR files. But these two WAR files share common application libraries. The two WAR files are build and added to EAR. When this EAR is deployed, the common classes are loaded twice resulting in duplicate schedulers. How can these common libraries be loaded only once? should they be removed from one WAR file?

Thanks in adv
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
Is it possible to deploy the libraries separately?


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 507
Hello,
You cannot remove the from one of the WAR files as the WAR from which you remove the common jars cannot see the classes loaded by WAR that has the common JARs. These are the sibling class loaders.
I believe you need to put the common JAR at EAR level which then will be available and visible to both the Webapp classloaders. I say both because two WARs will have independant WebApp Classloaders which have EAR Classloader as their parent.
Rule of thumb is the classes loaded by Parent are visible in Child classloader but not vice-a-versa. Sibling classloaders do not see each others classes.

Regards,
Amit
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

Each .war has an independent isolated classloader (mandated by spec). If you have common classes which are required by both those wars, then you'll have to package them in a jar and place that jar in .ear/lib folder.

[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

Closing this thread. Continue in your duplicate thread http://www.coderanch.com/t/562500/EJB-JEE/java/Two-WAR-files-EAR. And please do not create duplicate threads henceforth.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two WAR files that have common jars to one EAR - Issue
 
Similar Threads
What is an EAR?
Deploying My project in Jboss server
Order in which class is searched
[JBoss 6.0 M2] Best approach to build and deploy an EAR archive
Two WAR files to an EAR