Two WAR files that have common jars to one EAR - Issue
Joined: Aug 21, 2010
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
Joined: Jun 22, 2005
Is it possible to deploy the libraries separately?
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.
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.