9-2 Developing Applications for Oracle WebLogic Server
Oracle recommends that you package a shared Java EE library into its appropriate archive file EAR, JAR, or WAR. However, for development purposes, you may
choose to deploy shared Java EE libraries as exploded archive directories to facilitate repeated updates and redeployments.
After the shared Java EE library has been registered, you can deploy Enterprise applications that reference the library. Each referencing application receives a reference
to the required library on deployment, and can use the modules that make up the library as if they were packaged as part of the referencing application itself. The library
classes are added to the classpath of the referencing application, and the referencing applications deployment descriptors are merged in memory with those of the
modules that make up the shared Java EE library.
In general, this topic discusses shared Java EE libraries that can be referenced only by Enterprise applications. You can also create libraries that can be referenced only by
another Web application. The functionality is very similar to application libraries, although the method of referencing them is slightly different. See
Section 9.8, Web Application Shared Java EE Library Information
for details.
9.1.1 Optional Packages
WebLogic Server supports optional packages as described in the Java EE 5.0 Specification, Section 8.2 Optional Package Support, with versioning described in
Optional Package Versioning see http:java.sun.comjavase6docstechnotesguidesextensionsve
rsioning.html . Optional packages provide similar functionality to Java EE
libraries, allowing you to easily share a single JAR file among multiple applications. As with Java EE libraries, optional packages must first be registered with WebLogic
Server by deploying the associated JAR file as an optional package. After registering the package, you can deploy Java EE modules that reference the package in their
manifest files.
Optional packages are also supported as Java EE shared libraries in weblogic.BuildXMLGen, whereby all manifests of an application and its modules
are scanned to look for optional package references. If optional package references are found they are added to the wlcompile and appc tasks in the generated build.xml
file.
Optional packages differ from Java EE libraries because optional packages can be referenced from any Java EE module EAR, JAR, WAR, or RAR archive or exploded
archive directory. Java EE libraries can be referenced only from a valid Enterprise application.
For example, third-party Web application Framework classes needed by multiple Web applications can be packaged and deployed in a single JAR file, and referenced by
multiple Web application modules in the domain. Optional packages, rather than Java EE libraries, are used in this case, because the individual Web application modules
must reference the shared JAR file. With Java EE libraries, only a complete Enterprise application can reference the library.
Note: WebLogic Server also provides a simple way to add one or more JAR
files to the WebLogic Server System classpath, using the lib subdirectory of the domain directory. See
Section 8.6, Adding JARs to the Domain lib Directory
.
Creating Shared Java EE Libraries and Optional Packages 9-3
9.1.2 Library Directories