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:
EAR
- webapp_module.WAR
- ejb_module.JAR
- app_commons.JAR
- all_jars.JAR
As an alternate (but sloppy) solution, you can also put all your third party jar files at the ear root and just add the /META-INF/MANIFEST.MF file as described earlier.
However, I've seen cases where third party tools use
stream = MyClass.class.getResourceAsStream(resource);
instead of
stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
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