I don't know how to structure my ear file in my context.
Here is my actual structure:
ear
--lib
--war1
--war2
--warA
--warB
In ear/lib, I have all common jars between wars. Everything works fine but my ear is heavy.
In fact, war1 and war2 share some jars. WarA and warB too.
I don't put these jars in ear/lib because warA/B don't use everything and war1/2 too.
Today, war1/2 come with every jars, so some jars are in double.
I would like to have something like this:
ear
--lib (common jars)
--war1
--war2
--something who comes with common jars for war1/2
--warA
--warB
--something who comes with common jars for warA/B
Like this, war1 and war2 will be lighter. Same thing for warA and war B.
Do you know if I can do that and what kind of archive I can use to do that ? jar, war, sar ? I'm on Jboss 5.1
Thanks
So the PROBLEM is: you've an ear with two sets of wars: each set use a different version of the same library (so the version used by the first set must be isolated from the second, and viceversa), and you don't want to have to place the same library several times in different places of the ear. A part of these libraries, you may have other libraries shared by all the modules.
Possible SOLUTION: You could add a new war for each of the sets, those will just contain the libraries shared by the rest of wars in the same set. Then,to make it work without classloading problems you should isolate each set by placing a jboss-classloading.xml conveniently configured in each of the wars WEB-INF directory, and in the META-INF/jboss-classloading.xml of the ear which keeps the wars.
So the structure would be something like:
yourapp.ear
|
|--lib
| |- place here the libraries shared by all the wars in the ear
|
|--META-INF
| |
| |-jboss-classloading.xml
|
|--war1SetA.war
| |
| |-WEB-INF
| |- jboss-classloading.xml
| |
| |- classes
|
|
|--war2SetA.war
| |
| |-WEB-INF
| |- jboss-classloading.xml
| |
| |- classes
|
|
|--libsSetA.war
| |
| |-WEB-INF
| |- jboss-classloading.xml
| |
| |- lib
| |-Place here the libraries used by wars of setA
|
|--war1SetB.war
| |
| |-WEB-INF
| |- jboss-classloading.xml
| |
| |- classes
|
|--war2SetB.war
| |
| |-WEB-INF
| |- jboss-classloading.xml
| |
| |- classes
|
|--libsSetB.war
|
|-WEB-INF
|- jboss-classloading.xml
|
|- lib
|-Place here the libraries used by wars of setB
The wars named libsSet* are used just to keep the libraries used by the wars of the same set.
The jboss-classloading.xml of the wars in set A should be similar to:
<classloading xmlns="urn:jboss:classloading:1.0"
domain="SetA"
export-all="NON_EMPTY"
import-all="true"
parent-domain="yourapp.ear"
parent-first="false">
</classloading>
And for wars in set B, it should be:
<classloading xmlns="urn:jboss:classloading:1.0"
domain="SetB"
export-all="NON_EMPTY"
import-all="true"
parent-domain="yourapp.ear"
parent-first="false">
</classloading>
IMPORTANT: the domain attribute must be the same for all the wars in the same set.
And finally the META-INF/jboss-classloading.xml in the ear file should be:
<classloading xmlns="urn:jboss:classloading:1.0"
domain="yourapp.ear"
export-all="NON_EMPTY"
import-all="true"
parent-first="false">
</classloading>
Another possible solution, similar to this one, would be placing the shared libraries of each set in one of the wars of the set, this way you wouldn't need a war just for libraries.