Class loaders in the Application Server runtime follow a delegation hierarchy that is illustrated in the following figure and fully described inTable 2–1.

Figure 2–1 Class Loader Runtime Hierarchy

The following table describes the class loaders in the Application Server.

Table 2–1 Sun Java System Application Server Class Loaders

 

Class Loader

Description

Bootstrap

The Bootstrap class loader loads the basic runtime classes provided by the JVM, plus any classes from JAR files present in the system extensions directory. It is parent to the System class loader. To add JAR files to the system extensions, directory, see Using the Java Optional Package Mechanism.

System

The System class loader loads Application Server launch classes. It is parent to the Shared Chain class loader. It is created based on the system-classpath attribute of the java-config element in the domain.xml file. In the Admin Console, select the Application Server component, the JVM Settings tab, and the Path Settings tab, then edit the System Classpath field. See Using the System Class Loader and java-config in Sun Java System Application Server Platform Edition 9 Administration Reference.

Shared Chain

The Shared Chain class loader loads most of the core Application Server classes. It is parent to the MBean class loader and the Common class loader. Classes specified by the classpath-prefix and classpath-suffixattributes of the java-config element in the domain.xml file are added to this class loader. In the Admin Console, select the Application Server component, the JVM Settings tab, and the Path Settings tab, then edit the Classpath Prefix or Classpath Suffix field.

The environment classpath is included if env-classpath-ignored="false" is set in the java-configelement.

Use classpath-prefix to place libraries ahead of Application Server implementation classes in the shared chain. The classpath-prefix is ideal for placing development and diagnostic patches. Use classpath-suffix to place libraries after implementation classes in the shared chain.

MBean

The MBean class loader loads the MBean implementation classes. See MBean Class Loading.

Common

The Common class loader loads classes in the domain-dir/lib/classes directory, followed by JAR files in thedomain-dir/lib directory. It is parent to the Connector class loader. No special classpath settings are required. The existence of these directories is optional; if they do not exist, the Common class loader is not created. See Using the Common Class Loader.

Connector

The Connector class loader is a single class loader instance that loads individually deployed connector modules, which are shared across all applications. It is parent to the LifeCycleModule class loader and the Application class loader.

LifeCycleModule

The LifeCycleModule class loader is created once per lifecycle module. Each lifecycle-module element’sclasspath attribute is used to construct its own class loader. For more information on lifecycle modules, seeChapter 13, Developing Lifecycle Listeners.

Application

The Application class loader loads the classes in a specific enabled individually deployed module or Java EE application. One instance of this class loader is present in each class loader universe; see Class Loader Universes. The Application class loader is created with a list of URLs that point to the locations of the classes it needs to load. It is parent to the Web class loader.

The Application class loader loads classes in the following order:

  1. Classes specified by the library-directory element in the application.xml deployment descriptor or the –-libraries option during deployment; see Application-Specific Class Loading

  2. Classes specified by the application's or module's location attribute in the domain.xml file, determined during deployment

  3. Classes in the classpaths of the application's sub-modules

  4. Classes in the application's or module's stubs directory

The location attribute points to domain-dir/applications/j2ee-apps/app-name or domain-dir/applications/j2ee-modules/module-name.

The stubs directory is domain-dir/generated/ejb/j2ee-apps/app-name or domain-dir/generated/ejb/j2ee-modules/module-name.

Web

The Web class loader loads the servlets and other classes in a specific enabled web module or a Java EE application that contains a web module. This class loader is present in each class loader universe that contains a web module; see Class Loader Universes. One instance is created for each web module. The Web class loader is created with a list of URLs that point to the locations of the classes it needs to load. The classes it loads are in WEB-INF/classes or WEB-INF/lib/*.jar. It is parent to the JSP Engine class loader.

JSP Engine

The JSP Engine class loader loads compiled JSP classes of enabled JSP files. This class loader is present in each class loader universe that contains a JSP page; see Class Loader Universes. The JSP Engine class loader is created with a list of URLs that point to the locations of the classes it needs to load.

Note that this is not a Java inheritance hierarchy, but a delegation hierarchy. In the delegation design, a class loader delegates classloading to its parent before attempting to load a class itself. A class loader parent can be either the System class loader or another custom class loader. If the parent class loader cannot load a class, the class loader attempts to load the class itself. In effect, a class loader is responsible for loading only the classes not available to the parent. Classes loaded by a class loader higher in the hierarchy cannot refer to classes available lower in the hierarchy.

The Java Servlet specification recommends that the Web class loader look in the local class loader before delegating to its parent. You can make the Web class loader follow the delegation inversion model in the Servlet specification by setting delegate="false" in the class-loader element of the sun-web.xml file. It is safe to do this only for a web module that does not interact with any other modules. For details, see class-loader in Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

The default value is delegate="true", which causes the Web class loader to delegate in the same manner as the other class loaders. You must use delegate="true" for a web application that accesses EJB components or that acts as a web service client or endpoint. For details about sun-web.xml, see The sun-web.xml File in Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

https://docs.oracle.com/cd/E19501-01/819-3659/beadf/index.html

The Class Loader Hierarchy--转载的更多相关文章

  1. Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)

    Acknowledgments I would like to thank Jacob Kjome for reviewing early drafts of this document. His c ...

  2. slf4j的简单介绍

    SLF4J,Simple Logging Facade for JAVA,是一个十分简单的的日志facade,对于不同的日志框架做了一个封装. 对比common logging,Common logg ...

  3. ssh项目部署到weblogic中问题总结

    部署到weblogic还是比较费劲的 ,不过基本上问题全是由于classloader顺序的问题引起的. 首先在web-inf底下添加weblogic.xml文件如下 <?xml version= ...

  4. tomcat源码剖析

    最近看Tomcat的源码的节奏还算是挺紧凑的,给人的感觉,tomcat的代码相对以前读的jetty的代码显得更有条理一些...当然这也是有可能是因为自己看的jetty的版本是比较老的,而看的Tomca ...

  5. verview of Spring Framework--转

    http://docs.spring.io/spring/docs/current/spring-framework-reference/html/overview.html 2. Introduct ...

  6. FLEX 图片拷贝

    在用FLEX做GIS相关的开发的时候,遇到一个问题.因为是监控类的系统,所以需要要求地图上的ICON的实时更新,从而会出现重复加载的情况.就是重复请求相同的图片用做背景,尤其是在加载的ICON较多的时 ...

  7. tomcat 组件研究一--启动过程总结

    作为java 开发者,从开始学习java 便知道tomcat 这个容器了,但是一直却没有怎么研究过它的内部结构,以前对tomcat的认识也仅仅局限在那几个常用的目录放什么东西,那几个常用的配置文件应该 ...

  8. Spring3.0官网文档学习笔记(二)

    1.3 使用场景 典型的成熟的spring web应用 spring使用第三方框架作为中间层 远程使用场景 EJB包装 1.3.1 依赖管理.命名规则(包)     spring-*.jar *号代表 ...

  9. Tomcat启动过程源码解读

    根据Tomcat源码来看一下Tomcat启动过程都做了什么 部分代码为主要流程代码,删去了try-catch以及一些校验逻辑,方便理解主流程 先来一张启动过程时序图,了解一下启动顺序 Tomcat启动 ...

  10. java底层学习

    额,马上就要面试了,Java的底层肯定是需要了解的.网上找了找java的底层文章,做个记号.java底层主要是类的加载.连接和初始化. 本文主要分为四个方面: (1)java底层概述 (2)new和n ...

随机推荐

  1. Java多线程初学者指南(12):使用Synchronized块同步变量

    我们可以通过synchronized块来同步特定的静态或非静态方法.要想实现这种需求必须为这些特性的方法定义一个类变量,然后将这些方法的代码用synchronized块括起来,并将这个类变量作为参数传 ...

  2. C语言清空输入缓冲区的N种方法对比

    转自C语言清空输入缓冲区的N种方法对比 C语言中有几个基本输入函数: //获取字符系列 int fgetc(FILE *stream); int getc(FILE *stream); int get ...

  3. bzoj2333

    好题,先离线把连通块变成连续的区间每次连通块合并就相当于两个区间合并这样就轻易的用线段树解决了 type node=record wh:string[]; x,y:longint; end; ..*] ...

  4. bzoj1984

    树链剖分在边上的应用比维护点稍微麻烦一点,是对每条边标号,并且要记录每个点父亲边的编号和重儿子然后注意各种细节线段树上和bzoj1858的维护方法类似,覆盖的优先级高于加具体见程序,完全是为了提升状态 ...

  5. bzoj3238

    都LCP了很显然是要用到后缀数组的 显然前面的那个东西是可以直接算出来的 关键在于LCP的和怎么快速的计算 不难想到穷举height[i],然后判断这个height[i]可能成为多少对后缀的LCP 考 ...

  6. C++ const&的一个特性

    最近在搜索类似scope exit的实现时,除了发现已经有人向标准委员会提出意见,还得到一些意外的C++特性,这个特性一直都存在,而且很有趣 http://herbsutter.com/2008/01 ...

  7. java中计时器的用法Timer和TimerTask的用法__java中利用Timer与TImerTask 计时器间隔执行任务

          经常我们都会有这样的需求,要固定的每隔一段时间执行某一个任务.比如:   我们做一个缓存来减少与数据库的交互,而为了使缓存与数据库中的数据尽量达到同步,需要每个固定的一段时间去数据库中的数 ...

  8. Hadoop Yarn内存资源隔离实现原理——基于线程监控的内存隔离方案

    注:本文以hadoop-2.5.0-cdh5.3.2为例进行说明.   Hadoop Yarn的资源隔离是指为运行着不同任务的“Container”提供可独立使用的计算资源,以避免它们之间相互干扰.目 ...

  9. [C#]网络编程系列专题二:HTTP协议详解

    转自:http://www.cnblogs.com/zhili/archive/2012/08/18/2634475.html 我们在用Asp.net技术开发Web应用程序后,当用户在浏览器输入一个网 ...

  10. android studio class org.bouncycastle.asn1.asn1primitive overrides final method equals

    好吧 上手as 又遇到一个问题: class org.bouncycastle.asn1.asn1primitive overrides final method equals... 项目运行的是后报 ...