Troubleshooting
Problem
Applications can have dependency for external libraries in the form of jar files or zipped archives. This document details the steps to specify external dependencies to applications running on WebSphere® Application Server Community Edition.
Resolving The Problem
There are 3 ways by which external dependencies can be specified for applications.
- Specifying dependencies by adding to repository
- Use the Shared Library feature
- Specifying dependencies stored outside the application server directory by adding a GBean to deployment plan
Specifying dependencies by adding to repository
- Launch the Administrative Console.
- Open the Add Archive to Repository wizard.
- Choose Common Libs under Services.
- Repository Viewer is displayed with Add Archive to Repository wizard.
- Fill the form as shown in the screen shot below. Add the dependency using Install after filling the form.
The example shows the steps to add sample.jar as a dependency.
- On successful installation the newly added jar, car or rar will be displayed in Repository Viewer under Current Repository Entries.
- Choose the newly added entry to view usage of dependency in an application or module.
- Add a dependency element under dependencies in environment element in the deployment plan as shown below.
Note: Change the Version field to add a different version of the same jar file. |
Steps to add external dependency using Shared Library
- Copy zip or jar files to <Installation_Directory>/var/shared/lib
- Add a dependency on artifact sharedlib in the deployment plan as follows.
<environment> ...
...
|
Specifying dependencies outside the application server directory
To add libraries located outside application server directory you need to add a GBean element to the deployment plan of the application.
- Consider a sample application which refers to two directories for dependencies C:\mylib1\myjarfile1.jar and C:\mylib2\myjarfile2.jar
- Add gbean in the deployment plan to specify the dependency as follows:
... <context-root>MyApp</context-root> <gbean name="SharedLib1" class="org.apache.geronimo.system.sharedlib.SharedLib"> <attribute name="libDirs">c:/mylib1,c:/mylib2</attribute> <reference name="ServerInfo"> <name>ServerInfo</name> </reference> </gbean> ... </web-app> |
- Consider a sample application which refers to a property file for dependencies C:\myProperty\sample.properties
- Add gbean in the deployment plan to specify the dependency as follows:
... <context-root>MyApp</context-root> <gbean name="SharedLib1" class="org.apache.geronimo.system.sharedlib.SharedLib"> <attribute name="classesDirs">C:/myProperty</attribute> <reference name="ServerInfo"> <name>ServerInfo</name> </reference> </gbean> ... </web-app> |
The dependency specified by shared library is useful when we have multiple applications using multiple set of libraries. In this case it becomes cumbersome to add dependency element for each library in each application deployment plan
[{"Product":{"code":"SS6JMN","label":"WebSphere Application Server Community Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"2.1.1.2;2.1.1.1;2.1.0.1;2.1;2.0.0.3;2.0.0.2;2.0.0.1;2.0;1.1.0.2","Edition":"Entry;Enhanced;Elite","Line of Business":{"code":"LOB45","label":"Automation"}}]
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21266061