WebLogic to GlassFish : Sharing classes using APP-INF
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
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 .
element in META-INF/application.xml to reference the current location where the shared jar files are packaged.
Note that the
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
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee"
Otherwise, the deployment will fail with the following error in
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