One way of using Java™ libraries with an application is to include them in the application
itself. This might not always be desirable or appropriate, especially
if the application is already packaged and does not include the library.
About this task
In the following example, a library called
Alexandria consists of two files:
- alexandria-scrolls.jar and
- commons-lang.jar
An application called
Scholar, running on a
server called
Academy, needs access to this library.
Procedure
- Create a mylib/Alexandria directory
in the servers/Academy directory under the ${WLP_USER_DIR} directory.
For example: wlp/usr/servers/Academy/mylib/Alexandria.
- Copy the alexandria-scrolls.jar and commons-lang.jar files into the new folder.
- Configure class loading for the application, so that the Alexandria library is loaded.
In the
server.xml file, or an included file, add the following
code:
<application id="scholar" name="Scholar" type="ear" location="scholar.ear">
<classloader>
<privateLibrary>
<fileset dir="${server.config.dir}/mylib/Alexandria" includes="*.jar" scanInterval="5s" />
</privateLibrary>
</classloader>
</application>
Note: The <privateLibrary> element
can also take a filesetRef attribute with a comma-separated
list of <fileset> element IDs.