Using a Java library with a Java EE application

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

  1. Create a mylib/Alexandria directory in the servers/Academy directory under the ${WLP_USER_DIR} directory.

    For example: wlp/usr/servers/Academy/mylib/Alexandria.

  2. Copy the alexandria-scrolls.jar and commons-lang.jar files into the new folder.
  3. 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.

Icon that indicates the type of topic Task topic



Timestamp icon Last updated: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_classloader_use_lib
File name: twlp_classloader_use_lib.html