By default, Java™ EE applications do not have access
to the third-party APIs available in Liberty.
To enable this access, the application must be configured in the server.xml file,
or an included file.
About this task
In the following example, an application that is called Scholar needs access to
the third-party APIs that are available in Liberty.
The application also uses a common library called Alexandria. This library is
located in the ${server.config.dir}/mylib/Alexandria directory.
Avoid trouble: Third-party APIs might not remain compatible after an
upgrade. For more information, see
Liberty externals support.
Procedure
- Configure class loading for the application so that the application can access the third-party
APIs.
The default value for the apiTypeVisibility attribute of the
classloader element is spec, ibm-api, api, stable. Where
spec represents public specification APIs available for both compile and run time,
ibm-api represents APIs available in Liberty. The value api
represents public APIs available for both compile and run time, and stable
represents stable third party specification APIs available by default for both compile and run time.
Including third-party in the apiTypeVisibility attribute of the
classloader element makes third-party APIs available.
In the
server.xml file, or an included file, configure the API type visibility
by adding the following
code:
<application id="scholar" name="Scholar" type="ear" location="scholar.ear">
<classloader apiTypeVisibility="spec, ibm-api, third-party" commonLibraryRef="Alexandria" />
</application>
- If the application uses any common libraries, set those libraries to use the same API type
visibility setting.
In the
server.xml file, or an included file, add the following
code:
<library id="Alexandria" apiTypeVisibility="spec, ibm-api, third-party">
<fileset dir="${server.config.dir}/mylib/Alexandria" includes="*.jar" scanInterval="5s" />
</library>