File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 1527
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: 515
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: 10240
    
168

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: 10240
    
168

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