WebSphere Class Loaders and Shared Library, Part 2 (Class Loaders)

following part 1..

Class Loaders

1.     Class Loader Types

·        The bootstrap, extensions, and CLASSPATH class loaders created by the Java virtual machine

·        A WebSphere extensions class loader

·        One or more application module class loaders that load elements of enterprise applications running in the server

·        Zero or more Web module class loaders

Important Notes:

·        Each class loader is a child of the previous class loader.

·        Requests can only go to a parent class loader; they cannot go to a child loader. If WebSphere extensions class loader is requested to find a class in Application module class loader, a ClassNotFoundException occurs.

2.     Class loader isolation policies

Two class-loader policies control the isolation of applications and modules:

Class-loader scope

Class loader policy

Description

Where to set?

 Application

Single:  applications are not isolated

Application class loaders load EJB modules, dependency JAR files, embedded resource adapters, and application-scoped shared libraries. Depending on the application class-loader policy, an application class loader can be shared by multiple applications (Single) or unique for each application (Multiple). The application class-loader policy controls the isolation of applications that are running in the system.

On the WAS Admin Console, navigate to Servers -> Application Server, select the AppServer where your application will run. On the configuration tab, you will see the Classloader policy combo box.

Multiple: applications are isolated from each other.

WAR

Application: the Web module contents also are loaded by the application class loader

By default, Web module class loaders load the contents of the WEB-INF/classes and WEB-INF/lib directories. The application class loader is the parent of the Web module class loader. You can change the default behavior by changing the Web application archive (WAR) class-loader policy of the application.

The WAR class-loader policy controls the isolation of Web modules.

·        Admin Console->Applications-> Enterprise Applications, select the application you want. On the configuration, you will see the WAR class loader policy.

·        Or, on the workspace,you could open the Application Deployment Descriptor, go to Deployment -> Application. In the Applications list, select the EAR file, on the right side, you could see the WAR class loader policy.

Module: each Web module receives its own class loader whose parent is the application class loader

 

3.     Class loader modes

Two values for a class-loader mode are supported:

Class-loader mode

Description

Parent first

The Parent first class-loader mode causes the class loader to delegate the loading of classes to its parent class loader before attempting to load the class from its local class path. This value is the default for the class-loader policy and for standard JVM class loaders.

Parent last

The Parent last class-loader mode causes the class loader to attempt to load classes from its local class path before delegating the class loading to its parent. Using this policy, an application class loader can override and provide its own version of a class that exists in the parent class loader.

The following settings determine the mode of a class loader:

  • If the application class-loader policy of an application server is Single, the server-level mode value defines the mode for an application class loader.
  • If the application class-loader policy of an application server is Multiple, the application-level mode value defines the mode for an application class loader.
  • If the WAR class-loader policy of an application is Module, the module-level mode value defines the mode for a WAR class loader.

Class loader scope

Where to set

WebSphere extentions

Admin Cosole->Servers->Application Servers->..->Class loading mode

 

Application extentions

? (Not sure )Admin Cosole->Servers->Application Servers->..->Java and Process Management -> Class loader -> 

 

Application module

·        Admin Cosole ->Applications-> Enterprise Applications->..->Class loader mode

·        Application Deployment Descriptor->Deployment->Application

Web Module

·        Admin Cosole ->Applications-> Enterprise Applications->..->Web modules ->..->Class loader mode

·        Application Deployment Descriptor->Deployment->Application

 
to be continued ...

Resources:

Shared Libraries: WAS6 InfoCenter (Setting up the application serving environment->Administrating application servers-> Managing shared libraries)

Class Loaders: WAS6 InfoCenter (Developing and deploying applications->Class loading)

Classloading in WebSphere Portal: WebSphere Portal InfoCenter (Developing portlets->Portlet development basics->Creating a simple portlet)

Best Practice for Using Common Application Files

Learning more about the Classloader

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值