I have a situation where I have several jars that I want to include in an EAR file. The problem that I am running into is that some of the jar files reference properties in their respective manifests. If I execute the classes and have the appropriate jar files in the classpath, they retrieve the information. But when I create the EAR file, when the classes get called they return null for the values as if the manifest is not in the classpath.
How can I create the EAR using Ant where it will add the classpath information to the manifest of the EAR file?
Originally posted by Randall Stevens: Is there anyone out there with an answer? Placing the files in the lib and creating the EAR did not seem to work in this situation.
Hi, the solution is fairly easy and you don't need the APP-INF directory. Last time I checked, that trick was Weblogic specific.
1. Create a MANIFEST.MF file in a META-INF directory. 2. Reference all your third party jar files in your MANIFEST.MF file. 3. Create an new jar file. Call it something like "all_jars.jar" 4. Put all your third party jars in "all_jars.jar". 5. Include the META-INF (with MANIFEST.MF in it) in "all_jars.jar". 6. Include "all_jars.jar" in your ear file. That's it. This works for instance with the following ear structure:
As a result, the classes in these jar files were able to find and load resources and other classes when their jar file was deployed in the server system classpath, but not when sitting inside an ear file. In these rare cases, you have no other solution but to patch some of these tools' classes to make them use the currentThread context classloader. One example of this is the Hibernate ORM framework which is unable to load its xml config file when both the Hibenate jar and the xml file are packaged inside an ear file.
I hope this helps. Cheers
bacon. tiny ad:
a bit of art, as a gift, that will fit in a stocking