WebLogic J2EE Libraries: Common Operations and Problems

This topic explains common operations and problems associated with Weblogic J2EE libraries.

Terms

WebLogic J2EE library: A J2EE library is an Enterprise Application Archive, a stand-alone EJB, a Web Application module, or a JAR file that is registered with the 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 J2EE libraries, see J2EE Library: Overview in the WebLogic Server documentation.

Library reference: WebLogic J2EE 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.

Note that the library name does not necessary reflect its specification version or implementation version. For example, the library named beehive-netui-1.0.1-10.0 can have the version number 1.0 and the implementation number 1.0.2.2.

Libraries registry (or registry): The list of known WebLogic J2EE Libraries which is used to resolve library reference. In the IDE, the registry can be viewed and manipulated using the workspace preference page located at Window > WebLogic >J2EE Libraries. At runtime, the registry is described in the domain's config.xml file.

Common Operations

Adding a library reference to the project classpath

1. Select the project in question in the Project Explorer view.
2. Select Project > Project Properties.
3. Located the Java Build Path node in the tree on the left-hand-side of the dialog and select it.
4. Open the Libraries tab.
5. Click the Add Library button.
6. Select WebLogic J2EE Library and click Next.
7. Click Browse and choose the library that should be referenced.
8. Adjust the reference information as necessary.
9. Click Finish.

Modifying a library reference on the project classpath

1. Select the project in question in the Project Explorer view.
2. Select Project > Project Properties.
3. Located the Java Build Path node in the tree on the left-hand-side of the dialog and select it.
4. Open the Libraries tab.
5. Find the entry in the list of libraries called WebLogic J2EE Library [<library-name>] and select it.
6. Click Edit.
7. Review the library reference. If any changes are necessary, make the changes and click on the Finish button.

Removing a library reference from the project classpath

1. Select the project in question in the Project Explorer view.
2. Select Project > Project Properties.
3. Located the Java Build Path node in the tree on the left-hand-side of the dialog and select it.
4. Open the Libraries tab.
5. Find the entry in the list of libraries called WebLogic J2EE Library [<library-name>] and select it.
6. Click Remove.

Adding a library reference to the deployment descriptor

1. Select and expand the project in question in the Project Explorer view.
2. Locate the node labeled WebLogic Deployment Descriptor and expand it.
3. Find the node labeled J2EE Libraries.
4. Right-click on the J2EE Libraries node and select Add.
5. Click Browse and choose the library that should be referenced.
6. Adjust the reference information as necessary.
7. Click on the Ok button.

Modifying a library reference in the deployment descriptor

1. Select and expand the project in question in the Project Explorer view.
2. Locate the node labeled WebLogic Deployment Descriptor and expand it.
3. Find the node labeled J2EE Libraries
4. Locate the library in question, right-click it and select Edit.

Removing a library reference from the deployment descriptor

1. Select and expand the project in question in the Project Explorer view.
2. Find the node labeled WebLogic Deployment Descriptor and expand it.
3. Find the node labeled J2EE Libraries and expand it.
4. Locate the library in question, right-click it and select Remove.

Adding a new library to the registry

1. Select the Window menu from the menu bar and choose Preferences.
2. Find the WebLogic node in the tree on the left-hand-side of the dialog.
3. Expand the WebLogic node and selected the J2EE Libraries node.
4. Click on the Add button.
5. Click on the Browse button next to the Location field.
6. Find the library archive where it is located on disk and close the browse dialog.
7. Verify the information presented in the Attributes section. The library name, the specification version and the implementation version can be changed by using the Attributes table as long as they are not specified in the libraries manifest.mf file.
8. Click Ok.

Common Problems

This section lists error and warning messages that may appear in the Problems view. Resolutions are provided for each error/warning message.

Errors

1. Unable to resolve the reference to "<library-name>" library on project classpath.

Problem: The library reference to a WebLogic J2EE 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.

2. Unable to resolve the reference to "<library-name>" library in the deployment descriptor.

Problem: The library reference to a WebLogic J2EE 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 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 in the deployment descriptor.

Resolution 3: Remove the library from the deployment descriptor. For instructions on how to do this, see Removing a library reference from the deployment descriptor.

3. "<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 J2EE 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 runtime since WebLogic Server will not know how to make this library available for use by this module.

Resolution 1: Add a library reference to the EAR project weblogic-application.xml file. For instructions on how to do this, see Adding a library reference in the deployment descriptor.
 
Resolution 2: Remove the library from the project classpath. For instructions on how to do this, see Removing a library reference from the project classpath.

4. "<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 J2EE Library, but the weblogic.xml file does not reference this library. This could lead to problems at runtime since WebLogic Server will not know how to make this library available for use by this module.

Resolution 1: Add a library reference to this project’s weblogic.xml file. For instructions on how to do this, see Adding a library reference in the deployment descriptor.
 
Resolution 2: Remove the library from the project classpath. For instructions on how to do this, see Removing a library reference from project classpath.

5. "<library-name>” library is a web library and cannot be referenced by this project.

Problem: WebLogic Server only allows classes in a WAR-type WebLogic J2EE 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 project classpath.

6. "<library-name>" library reference is not allowed in the weblogic.xml file. Only WAR libraries are allowed.

Problem: 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. For instructions on how to do this, see Removing a library reference from the deployment descriptor.

7. 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 runtime 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 J2EE Module Dependencies. Locate the project in the list and place a checkmark next to it. Click Finish to associate the project with the EAR project.

8. 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 runtime if this project is part of a web application and the web applications 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 J2EE Module Dependencies. Switch to the Web Libraries tab. Locate the project in the list and place a checkmark next to it. Click Finish to associate the project with the web project.

Warnings

1. 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 runtime because the project could be compiled against a different version of the library than what will be used at runtime.

Resolution 1: 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.

Resolution 2: Modify the library reference in the EAR project’s weblogic-application.xml file so it matches the library reference on the project classpath. For instructions on how to do this, see Modifying a library reference in the deployment descriptor.

2. 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 runtime because the project could be compiled against a different version of the library than what will be used at runtime.

Resolution 1: 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 project classpath.

Resolution 2: Modify the library reference in the project's weblogic.xml file so it matches the library reference on the classpath. For instructions on how to do this, see Modifying a library reference in the deployment descriptor.


Still need help? Post a question on the Workshop newsgroup.