+

Search Tips   |   Advanced Search

Set Web module class loaders



Overview

We can set values that control the class-loading behavior of an installed Web module.

This page assumes that you installed a Web module on an application server.

Set the class loader order value of an installed Web module. By default, a Web module has its own WAR class loader to load the contents of the Web module, which are in...

An application class loader is the parent of a WAR class loader. The WAR class-loader policy value of an application class loader determines whether the WAR class loader or the application class loader is used to load the contents of the Web module.

The default WAR class loader policy value is...

Class loader for each WAR file in application

If the policy is set to Class loader for each WAR file in application, then each Web module receives its own class loader whose parent is the application class loader.

If the policy is set to Single class loader for application, then the application class loader loads the Web module contents as well as the EJB modules, shared libraries, resource adapter archive (RAR) files, and dependency JAR files associated to an application.

The configuration of the parent application class loader affects the WAR class loader. We can set the policy on the Class loading and update detection page of an admin console.

Use the admin console to configure the application and WAR class loaders.

If an application is running, changing an application setting causes the application to restart. On stand-alone servers, the application restarts after you save the change. On multiple-server products, the application restarts after you save the change and files synchronize on the node where the application is installed. To control when synchronization occurs on multiple-server products, deselect Synchronize changes with nodes on the Console preferences page.


Procedure

  1. If we have not done so already, configure the application class loader.

    Settings such as Override class reloading settings for Web and EJB modules, Polling interval for updated files and WAR class loader policy can affect Web module class loading.

    If WAR class loader policy is set to Class loader for each WAR file in application, then the Web module receives its own class loader and the WAR class-loader policy of the Web module defines the mode for a WAR class loader.

    If the policy is set to Single class loader for application, then the application class loader loads the Web module contents.

  2. Specify the class loader order for the installed Web module.

    The Web module class-loader mode specifies whether the class loader searches in the parent application class loader or in the WAR class loader first to load a class. The default is to search in the parent application class loader before searching in the WAR class loader to load a class.

    Select either of the following values for Class loader order:

    Option Description
    Classes loaded with parent class loader first Causes the class loader to search in the parent application class loader first to load a class. This is the standard for Development Kit class loaders and WAS class loaders.

    Best practice: If classes and resources needed by the Web module cannot be accessed by the application class loader, but can be accessed by the WAR class loader, specify Classes loaded with local class loader first (parent last). If the application class loader cannot find a class, the class loader delegates the request to find the class to its parent, the WAS extensions class loader. If the WAS extensions class loader cannot find the class, the class loader delegates the request to its parent, the bootstrap, extensions, and CLASSPATH class loaders created by the Java virtual machine. Requests can only go to a parent class loader; they cannot go to a child class loader. Thus, if Classes loaded with parent class loader first is specified, the WAR class loader never receives a request to load a class

    Classes loaded with local class loader first (parent last) Causes the class loader to search in the WAR class loader first to load a class. By specifying Classes loaded with local class loader first (parent last), the WAR class loader can override classes contained in the parent application class loader.

    Avoid trouble: Specifying the Classes loaded with local class loader first (parent last) value might result in LinkageErrors or ClassCastException messages if we have mixed use of overridden classes and non-overridden classes.

  3. Click OK.

 

Next steps

Save the changes to the admin configuration.


Class loaders

 

Related tasks


Install enterprise application files
Set application class loaders
Class loading

 

Related


Class loading and update detection settings
Web module deployment settings