WebLogic application server supports sharing of utility classes in an ear file. The shared utility classes can be packaged in one of two directories :
- APP-INF/lib : shared jar files can be placed here.
- APP-INF/classes : individual classes can be placed here.
The problem is that APP-INF is proprietary to WebLogic and non portable.
Migration Path to GlassFish:
Use the portable mechanism for sharing introduced in Java EE 5 specification. Java EE specification defines the following.
"A .ear file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the .ear file's deployment descriptor contains the name of this directory. If a library-directory element isn't specified, or if the .ear file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify that there is no library directory.
All files in this directory (but not subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients. These libraries may reference other libraries, either bundled with the application or installed separately, using any of the techniques described herein."
To migrate a shared jar file, foo.jar packaged in APP-INF/lib/foo.jar, do one of the following:
- move APP-INF/lib/foo.jar to lib/foo.jar .
- use <library-directory> element in META-INF/application.xml to reference the current location where the shared jar files are packaged.
<application> <library-directory>APP-INF/lib</library-directory> </application>
Note that the <library-directory> is new for Java EE 5 and is defined by the XML Schema for Version 5 of application.xml ( http://java.sun.com/xml/ns/javaee/application_5.xsd ). The META-INF/application.xml being migrated might contain the DTD for the older version of application.xml. In this case, replace the DTD with the following:
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">
Otherwise, the deployment will fail with the following error in server.log.
Deploying application in domain failed; Deployment descriptor file META-INF/application.xml in archive [archive-file-name]. Element type "library-directory" must be declared.
To migrate shared individual classes in APP-INF/classes, package the classes into a jar file and add them to the lib directory.