Do I need to repeat common JAR messages through WARs in the EAR?

I have a JAR file for authorization. I need this for each of my WAR files. All WAR files are packaged in an EAR file. Should I repeat this common JAR in every WAR, or is there a structure for shared libraries?

So my example looks something like this:

big.ear - META-INF - MANIFEST.MF - application.xml - appl1.war - META-INF - MANIFEST.MF - WEB-INF - web.xml - lib - unique1.jar - unique2.jar - unique3.jar - common1.jar - jsps/html/etc - appl2.war - META-INF - MANIFEST.MF - WEB-INF - web.xml - lib - unique3.jar - unique4.jar - common1.jar - jsps/html/etc - appl3.war - META-INF - MANIFEST.MF - WEB-INF - web.xml - lib - unique5.jar - common1.jar - jsps/html/etc 

Each of my WAR applications can see common1.jar, but it is in the EAR three times.

Where in the EAR structure can I put common1.jar so that appl1, appl2 and appl3 can see it without repeating it three times?

+6
java java-ee enterprise-library
source share
3 answers

The standard way is to place the JARs in the root of your EAR and reference them in the Class-Path attribute of the WAR META-INF/MANIFEST.MF . See this article .

Check the documentation in the container to make sure it is supported.

+6
source share

Its in the JEE5 specification, chapter EE 8.2.1:

The .ear file may contain a directory containing libraries packaged in JAR files. The library-directory element of the .ear files for the deployment descriptor contains the name of this directory. If no directory library entry is specified or if the .ear file does not contain a deployment descriptor, a directory named lib b.

+1
source share

Your application server should have a folder, such as shared / lib, where you can put jar files that can be shared by several web folders in one instance.

-4
source share

All Articles