Posted by sekhar
on March 23, 2009 at 12:31 PM PDT
WebLogic applications can use APP-INF directory to package classes in a .ear file and share them between J2EE/Java EE modules. However, APP-INF is not a Java EE standard and is non portable. Here is a tip on how to migrate to GlassFish.
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 .
- use element in META-INF/application.xml to reference the current location where the shared jar files are packaged.
Note that the 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
<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