Bookmark Topic Watch Topic
  • New Topic

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

 
Ramu Nur
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Is it possible to deploy the libraries separately?
 
amit punekar
Ranch Hand
Posts: 544
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic