http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

      Bootstrap
          |
       System
          |
       Common
       /     \
  Webapp1   Webapp2 ... 


클래스 로더 계층 구조이다.


lass Loader Definitions

As indicated in the diagram above, Tomcat 6 creates the following class loaders as it is initialized:

  • Bootstrap - This class loader contains the basic runtime classes provided by the Java Virtual Machine, plus any classes from JAR files present in the System Extensions directory ($JAVA_HOME/jre/lib/ext). NOTE - Some JVMs may implement this as more than one class loader, or it may not be visible (as a class loader) at all.
  • System - This class loader is normally initialized from the contents of theCLASSPATH environment variable. All such classes are visible to both Tomcat internal classes, and to web applications. However, the standard Tomcat 6 startup scripts ($CATALINA_HOME/bin/catalina.sh or%CATALINA_HOME%\bin\catalina.bat) totally ignore the contents of the CLASSPATHenvironment variable itself, and instead build the System class loader from the following repositories:
    • $CATALINA_HOME/bin/bootstrap.jar - Contains the main() method that is used to initialize the Tomcat 6 server, and the class loader implementation classes it depends on.
    • $CATALINA_HOME/bin/tomcat-juli.jar - Package renamed Commons logging API, and java.util.logging LogManager.
  • Common - This class loader contains additional classes that are made visible to both Tomcat internal classes and to all web applications. Normally, application classes should NOT be placed here. All unpacked classes and resources in $CATALINA_HOME/lib, as well as classes and resources in JAR files are made visible through this class loader. By default, that includes the following:
    • annotations-api.jar - JEE annotations classes.
    • catalina.jar - Implementation of the Catalina servlet container portion of Tomcat 6.
    • catalina-ant.jar - Tomcat Catalina Ant tasks.
    • catalina-ha.jar - High availability package.
    • catalina-tribes.jar - Group communication package.
    • el-api.jar - EL 2.1 API.
    • jasper.jar - Jasper 2 Compiler and Runtime.
    • jasper-el.jar - Jasper 2 EL implementation.
    • jasper-jdt.jar - Eclipse JDT 3.2 Java compiler.
    • jsp-api.jar - JSP 2.1 API.
    • servlet-api.jar - Servlet 2.5 API.
    • tomcat-coyote.jar - Tomcat connectors and utility classes.
    • tomcat-dbcp.jar - package renamed database connection pool based on Commons DBCP.
    • tomcat-i18n-**.jar - Optional JARs containing resource bundles for other languages. As default bundles are also included in each individual JAR, they can be safely removed if no internationalization of messages is needed.
  • WebappX - A class loader is created for each web application that is deployed in a single Tomcat 6 instance. All unpacked classes and resources in the /WEB-INF/classes directory of your web application archive, plus classes and resources in JAR files under the /WEB-INF/lib directory of your web application archive, are made visible to the containing web application, but to no others.

As mentioned above, the web application class loader diverges from the default Java 2 delegation model (in accordance with the recommendations in the Servlet Specification, version 2.3, section 9.7.2 Web Application Classloader). When a request to load a class from the web application's WebappX class loader is processed, this class loader will look in the local repositories first, instead of delegating before looking. There are exceptions. Classes which are part of the JRE base classes cannot be overriden. For some classes (such as the XML parser components in J2SE 1.4+), the J2SE 1.4 endorsed feature can be used. Last, any JAR containing servlet API classes will be ignored by the classloader. All other class loaders in Tomcat 6 follow the usual delegation pattern.

Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:

  • Bootstrap classes of your JVM
  • System class loader classes (described above)
  • /WEB-INF/classes of your web application
  • /WEB-INF/lib/*.jar of your web application
  • $CATALINA_HOME/lib
  • $CATALINA_HOME/lib/*.jar



SRV.9.7.2 Web Application Class Loader

The class loader that a container uses to load a servlet in a WAR must allow the
developer to load any resources contained in library JARs within the WAR
following normal J2SE semantics using getResource. As described in the J2EE
license agreement, servlet containers that are not part of a J2EE product should not
allow the application to override J2SE platform classes, such as those in the java.*
and javax.* namespaces, that J2SE does not allow to be modified. Also, servlet
containers that are part of a J2EE product should not allow the application to
override J2SE or J2EE platform classes, such as those in java.* and javax.*
namespaces, that either J2SE or J2EE do not allow to be modified. The container
should not allow applications to override or access the container’s implementation
Replacing a Web Application classes. 
It is recommended also that the application class loader be implemented so
that classes and resources packaged within the WAR are loaded in preference to
classes and resources residing in container-wide library JARs.


'Web service' 카테고리의 다른 글

Tomcat 7 Released  (0) 2010.07.02
AB (apache load generator) usage  (0) 2010.06.13
[Tomcat] STRICT_SERVLET_COMPLIANCE 내용  (0) 2010.06.03
톰캣 Connector 프로토콜 설정  (0) 2010.05.31
Tomcat7 Valve를 Filter로 바뀔까나~  (0) 2010.05.13
Posted by '김용환'
,