A WebLogic Shared Library is an Enterprise Application Archive, a stand-alone EJB, a Web Application module, or a JAR file that is registered with Oracle WebLogic Server as a shared library. The library resources can be shared between multiple applications, alleviating the need to have duplicate copies of the resources in each application. For an overview of WebLogic Shared Libraries, see "Deploying Shared Java EE Libraries and Dependent Applications" in Oracle Fusion Middleware Deploying Applications to Oracle WebLogic Server.
WebLogic shared libraries provide an easy way to share one or more types of Java EE modules among multiple applications.
A shared library can be one of the following:
Stand-alone EJB module
Stand-alone Web application module
Multiple EJB modules packaged in an EAR file
Multiple Web application modules packaged in a WAR file
Single JAR file that is registered with the application container
After the library has been registered, you can deploy multiple applications that reference the library. Each referencing application can use the library as if it were packaged as part of the referencing application itself. The shared library classes are added to the classpath of the referencing application, and the referencing application's deployment descriptors are merged (in memory) with those of the library.
A registry of shared libraries can be viewed and edited using the workspace Preference page accessible through Window > Preferences > WebLogic > Shared Libraries. At run time, the registry is described in the domain's config.xml file.
These are terms used when working with WebLogic Shared Libraries:
Library reference: WebLogic Shared Libraries are referenced indirectly by specifying the name of the library, the specification version (optional), the implementation version (optional) and whether a newer version of the library should be used if present. The library references are used on the project classpath and in the deployment descriptors (weblogic-application.xml and weblogic.xml). Library references are resolved against the libraries registry when necessary.
Libraries registry (or registry): The list of known WebLogic Shared Libraries which is used to resolve a library reference.
This section describes the following common operations associated with WebLogic shared libraries.
You can add new libraries to the registry.
To add a new library to the registry:
From the top-level menu, select Window > Preferences.
Find the WebLogic node in the tree on the left-hand-side of the dialog.
Select WebLogic > Shared Libraries from the list of preferences on the left.
Click Add.
Click Browse to select the library location.
Find the library archive where it is located on the disk, and select the library.
Verify the information presented in the Attributes section of the Add WebLogic Shared Library dialog. You can modify the library name, the specification version, and implementation version by using the Attributes table as long as they are not specified in the library's manifest.mf file.
Click OK.
You can add a library reference to the project classpath.
To add a library reference to the project classpath:
Right-click on the project in the Project Explorer view and select Properties from the drop-down menu.This will open the Properties dialog.
In the Properties dialog, select the Java Build Path from the list of properties.
In the Java Build Path part of the dialog, select the Libraries tab.
Click Add Library.
Select WebLogic Shared Library, and then click Next.
Click Browse, and choose the library that you want to reference.
Modify the reference information, if necessary.
Click Finish.
You can modify library references.
To modify a library reference on the project classpath:
Select the project in the Project Explorer view.
Choose Project > Project Properties.
Locate the Java Build Path node in the tree on the left-hand-side of the dialog and select it.
Open the Libraries tab.
Find the entry in the list of libraries called Shared Library library-name and select it.
Click Edit.
Review the library reference. If any changes are necessary, make the changes and click Finish.
You can remove library references.
To remove a library reference from the project classpath:
On the Properties dialog, select the Java Build Path from the list of properties.
On the Java Build Path part of the dialog, select the Libraries tab.
Find the entry in the list of libraries called Shared Library library-name, and then select it.
Click Remove.
This section lists error and warning messages that may appear in the Problems view. Resolutions are provided for each error/warning message.
Unable to resolve library reference on project classpath
Unable to resolve library reference in the deployment descriptor
Library on classpath but not in weblogic-application.xml
Library on classpath but not in weblogic.xml
Web library referenced by a non-Web project
Non-Web library referenced in weblogic.xml
Project must be part of an EAR to use this library
Project must be part of a web application to use this library
Unable to resolve the reference to "<library-name>" library on project classpath.
Problem: The library reference to a WebLogic Shared Library on the project classpath cannot be resolved using the workspace libraries registry. The project cannot be build.
Resolution 1: Add the appropriate library to the libraries registry. For instructions on how to do this, see Adding a new library to the registry.
Resolution 2: Modify the library reference to match what is present in the registry. For instructions on how to do this, see Modifying a library reference on the project classpath.
Resolution 3: Remove the library from the project classpath. For instructions on how to do this, see Removing a library reference from the project classpath.
Unable to resolve the reference to "<library-name>" library in the deployment descriptor.
Problem: The library reference to a WebLogic Java EE Library in the deployment descriptor (the weblogic.xml or weblogic-application.xml file depending on project type) cannot be resolved using the workspace libraries registry. The project many not run once deployed.
Resolution: Add the appropriate library to the libraries registry. For instructions on how to do this, see Adding a New Library to the Registry.
"<library-name>" library is on the classpath of this project, but is not in the weblogic-application.xml file of the EAR project "<EAR-project-name>".
Problem: The project contains a reference to a WebLogic Shared Library, but the weblogic-application.xml file of the EAR project that this project belongs to does not reference the library. This could lead to problems at run time since Oracle WebLogic Server will not know how to make this library available for use by this module.
Resolution: Remove the library from the project classpath. For instructions on how to do this, see Removing a Library Reference from the Project Classpath.
"<library-name>" library is on the classpath of this project, but is not in the weblogic.xml file.
Problem: The project contains a reference to a WebLogic Shared Library, but the weblogic.xml file does not reference this library. This could lead to problems at run time since Oracle WebLogic Server will not know how to make this library available for use by this module.
Resolution: Remove the library from the project classpath. For instructions on how to do this, see Removing a Library Reference from the Project Classpath.
"<library-name>" library is a web library and cannot be referenced by this project.
Problem: Oracle WebLogic Server only allows classes in a WAR-type WebLogic Shared Library to be visible to Web modules. While an EAR can reference such a library in the weblogic-application.xml, none of the classes in the referenced library will be visible to the classes in the EAR.
Resolution: Remove the library from the project classpath. For instructions on how to do this, see Removing a Library Reference from the Project Classpath.
"<library-name>" library reference is not allowed in the weblogic.xml file. Only WAR libraries are allowed.
Problem: Oracle WebLogic Server only supports WAR libraries to be referenced from the weblogic.xml deployment descriptor. A non-WAR library has been referenced in the descriptor.
Resolution: Remove the library from the weblogic.xml deployment descriptor.
This project must be part of an EAR in order to use "<library-name>" library.
Problem: The library referenced on the classpath of this project can only be accessed at run time if this project is part of an EAR and the EAR's weblogic-application.xml deployment descriptor references this library.
Resolution 1: Remove the library from the project classpath. For instructions on how to do this, see Removing a Library Reference from the Project Classpath.
Resolution 2: Create a new EAR project (or use an existing one). In the EAR project's Properties (right-click the EAR and select Properties) select the page labeled Java EE Module Dependencies. Select the project from the list, and then click Finish to associate the project with the EAR project.
This project must be part of a web application in order to use "<library-name>" library.
Problem: The library referenced on the classpath of this project can only be accessed at run time if this project is part of a Web application, and the Web application's weblogic.xml deployment descriptor references this library.
Resolution 1: Remove the library from the project classpath. For instructions on how to do this, see Removing a Library Reference from the Project Classpath.
Resolution 2: Create a new Dynamic Web project (or use an existing one). In the Web project's Properties (right-click the Web project, and select Properties) select the page labeled Java EE Module Dependencies. Select the Web Libraries tab. Select the project from the list, and then click Finish to associate the project with the Web project.
This section lists warning messages that may appear in the Problems view. Resolutions are provided for each warning message.
Classpath reference differs from weblogic-application.xml
Classpath reference differs from weblogic.xml
The reference to the "<library-name>" library on this project's classpath differs from the reference to this library in the weblogic-application.xml file of the EAR project "<EAR-project-name>".
Problem: The library reference on the module project's classpath differs from the library reference in the weblogic-application.xml file of the EAR project that this module project belongs to. This could lead to problems at run time, because the project could be compiled against a different version of the library than what will be used at run time.
Resolution: Modify the library reference on the project classpath so it matches the library reference in the EAR project's weblogic-application.xml file. For instructions on how to do this, see Modifying a Library Reference on the Project Classpath.
The reference to the "<library-name>" library on this project's classpath differs from the reference to this library in the weblogic.xml file.
Problem: The library reference on this project's classpath differs from the library reference in the weblogic.xml file. This could lead to problems at run time, because the project could be compiled against a different version of the library than what will be used at run time.
Resolution: Modify the library reference on the project classpath so it matches the library reference in the weblogic.xml file. For instructions on how to do this, see Modifying a Library Reference on the Project Classpath.