Associate shared libraries with applications or modules
We can associate a shared library with an application or module. Classes represented by the shared library are then loaded in the application's class loader, making the classes available to the application.
This topic assumes that you have created a shared library. The shared library represents a library file used by multiple deployed applications.
We can define a shared library at the cell, node, server, or cluster level.
On a multiple-server product, you also can define a shared library at the cluster level. To see the cluster scope, you first must create a cluster on the Server clusters page (Servers > Clusters > WebSphere application server clusters).
This topic also assumes to use the console, and not an installed optional package, to associate a shared library with an application.
To associate a shared library with an application or module, create and configure a library reference using the console. A library reference specifies the name of the shared library file.
If we associate a shared library with an application, do not associate the same shared library with a server class loader.
- If we have not done so already, map the application to a target server that is within the scope of the shared library.
For example, if the shared library scope is the my_cluster cluster, map the application to the target my_cluster cluster.
- Click Applications > Application Types > WebSphere enterprise applications > application_name > Shared library references in the console navigation tree to access the Shared library references page.
- On the Shared library references page, select an application or module to which to associate a shared library.
- Click Reference shared libraries.
- On the Shared library mapping page, select one or more shared libraries that the application or modules use in the Available list, click >> to add them to the Selected list, and click OK.
- Repeat steps 2 through 4 until you define a library reference instance for each shared library that the application or module requires.
- On the Shared library references page, click OK.
- Save the changes to the configuration.
When you run the application, classes represented by the shared library are loaded in the application class loader.
The classes are now available to the application or module.
What to do next
To verify an association between an application and a shared library, examine the application class loader in the Class loader viewer. Click Troubleshooting > Class loader viewer > module_name > Table View. The classpath of the application module class loader lists the classes used by the shared library.
- Shared library reference and mapping settings
Use the Shared library references and Shared library mapping pages to associate defined shared libraries with an application or web module. A shared library is an external JAR file used by one or more applications. Using shared libraries enables multiple applications deployed on a server to use a single library, rather than use multiple copies of the same library. After you associate shared libraries with an application or module, the application or module class loader loads classes represented by the shared libraries and makes those classes available to the application or module.
Class loaders Installed optional packages
Mapping modules to servers Create shared libraries Associate shared libraries with servers Manage shared libraries Use installed optional packages
Shared library relationship and mapping settings Shared library collection Library reference collection