Classloader modes
There are two possible values for a classloader mode. These values can be changed using the WebSphere administrative console.
PARENT_FIRST
The PARENT_FIRST classloader mode causes the classloader to first delegate the loading of classes to its parent classloader (the classloader up one level in the classloader hierarchy) before attempting to load the class from its local classpath. This is the default classloader policy for all classloaders. This default can be changed for the classloaders supplied by the WebSphere run time. It can not be changed for the Java Virtual Machine classloaders.
PARENT_LAST
The PARENT_LAST classloader mode causes the classloader (the classloader up one level in the classloader hierarchy) to first attempt to load classes from its local classpath before delegating the classloading to its parent. This policy allows an application classloader to override and provide its own version of a class that exists in the parent classloader.
There are three Classloader mode settings:
There are several classloader policy and classloader mode settings in the WebSphere administrative console. See the topics below for more information:
Setting classloaders in application servers
Click Servers --> Application Servers --> server_name and, on the settings page for an application server, set the application classloader policy and application class loading mode.
The Application classloader policy controls the isolation of applications running in the system. When set to SINGLE, applications are not isolated; a single application classloader is used to contain all dependency JAR files in the system. When set to MULTIPLE, applications are isolated from each other; each application receives its own classloader to load that application's dependency JAR files.
The Application classloader mode specifies the classloader mode when the application classloader policy is SINGLE. This field is not used if the application classloader policy is MULTIPLE. PARENT_FIRST causes the classloader to first delegate the loading of classes to its parent classloader before attempting to load the class from its local classpath. PARENT_LAST causes the classloader to first attempt to load classes from its local classpath before delegating the classloading to its parent. This allows an application classloader to override and provide its own version of a class that exists in the parent classloader.
Setting classloaders in an application
Click Applications --> Enterprise Applications --> application_name and, on the settings page for an application server, set the WAR classloader policy and application classloading mode.
The WAR classloader policy specifies whether to use the application classloader to load all WAR files of this application or to use a separate classloader for each WAR file. By default, Web module classloaders load the contents of the WEB-INF/classes and WEB-INF/lib directories. The application classloader is the parent of the Web module classloader. You can change the default behavior by changing the application's WAR classloader policy.
The WAR classloader policy controls the isolation of Web modules. If this policy is set to APPLICATION, then the Web module contents also are loaded by the application classloader (in addition to the RAR files and dependency JAR files). If the policy is set to MODULE, then each web module receives its own classloader whose parent is the application classloader.
The application classloading mode specifies whether the classloader searches in the parent classloader or in the application classloader first to load a class. The standard for JDK classloaders and WebSphere Application Server classloaders is PARENT_FIRST. By specifying PARENT_LAST, your application can override classes contained in the parent classloader, but this action can potentially result in ClassCastException or LinkageErrors if you have mixed use of overridden classes and non-overridden classes.
The options are PARENT_FIRST and PARENT_LAST. The default is to search in the parent classloader before searching in the application classloader to load a class.
Setting classloaders in a Web module
Click Application -- > Enterprise Application --> application_instance --> Web Module --> Web Module_instance and, on the settings page for an Web module, set the web module classloder mode.
The Web module classloader mode Specifies whether the classloader should search in the parent classloader or in the application classloader first to load a class. The standard for JDK classloaders and WebSphere classloaders is PARENT_FIRST. By specifying PARENT_LAST, your application can override classes contained in the parent classloader, but this action can potentially result in ClassCastException or LinkageErrors if you have mixed use of overriden classes and non-overriden classes.
The options are PARENT_FIRST and PARENT_LAST. The default is to search in the parent classloader before searching in the application classloader to load a class.