The following rules covers approximately 95% of the content, regarding the work of developers and configurations, on where places files and resource files are placed to make them effective.
For classes and resource files that specific web applications, unpacking classes and resource files are placed under the / web-inf / class of your web application path, or place the JAR file containing those classes and resource files in / Web -Inf / lib
For web application classes and resource files shared for all web applications, there is no packaged class and resource files under $ catalina_home / shared / classes, or place those and resource file JAR packages in $ catalina_home / shared / Lib's below.
Preface
Like some service applications, Tomcat4 install a diversity of Class Loaders (that is, execute the java.lang.classloader) class to allow different parts and website applications of the container to run in this container, allowing access to different classes and resources. .
In the Java 2 (That IS, JDK 1.2 or Later) environment, Class Loaders is arranged in a parent-child tree. When a class loader is required to load a class and resource, he first specifically specifies this requirement to a parent class, then look for your own needs in this parent class, if you can't find it, look down. Class Loader for web applications may or have a subtle difference, but the main mechanisms are the same.
When Tomcat 4 Is Started, IT Creates A Set of Class Loaders That Are Organized Into The Following Parent-Child Relationships, WHERE The Parent Class Loader is Above The Child Class Loader:
When Tomcat4 is started, he created a set of Class Loaders of the following parent-child relationships, and the parent class on the subclass.
Bootstrap
|
SYSTEM
|
Common
/ /
Catalina Shared
/ /
WebApp1 WebApp2 ...
Each feature of these Class Loaders (source files including classes and resources) is described in the following sections.
Class Loader Definition
Just like the above chart, Tomcat4 creates the following Class Loader when initialization:
Bootstrap - This Class Loader contains the basic runtime of Java virtual machines, as well as any current system extension path ($ java_home / jre / lib / ext) JAR file. Note - Some Java virtual machines may require multiple Class Loader, or may be invisible.
System - This Class Loader is usually initialized from the content of the ClassPath environment variable. All of these classes are visible for Tomcat internal classes and web applications. But Tomcat4 standard start scripts ($ CATALINA_HOME / BIN / CATALINA.SH or% CATALINA_HOME% / BIN / CATALINA.BAT) completely ignore the content of his own ClassPath environment variable, which is replaced by establishing system Class Loader from the following warehouse:
$ Catalina_home / bin / bootstrap.jar - Contains the main method of initialization Tomcat4 services, and the Class Loader he depends on.
$ JAVA_HOME / lib / Tools.jar - contains the Javac compiler, used to compile JSP into a Sevlet class
Common - This Class Loader contains additional classes visible for Tomcat4 and all Wen applications. Typically, the application class should not be placed here. Through this type of loading, all unpacking classes and resource files under $ catalina_home / common / classes and the packaged JAR files under $ catalina_home / commit / endorsed and $ catalina_home / common / lib Directories can become visible . In the default, the following packages mainly include the following: JNDI.JAR - Java Names and Path Interface API class (only in JDK1.2 system is loaded because later JDK1.3 will be automatically included).
Naming-common.jar - uses Tomcat4 to explain the JNDI implementation of the memory naming
Naming-resources.jar - Demoded to describe a Web application static in the hospital's special JNDI naming association implementation
servlet.jar - Servlet and JSP API class
Xerces.jar - In the default, XML parsers visible for Tomcat internal classes and web applications. For a special application, we can contain our own parsers under / web-inf / lib to ignore this parser
Catalina - Contains all the needs of all the needs of all needs when Tomcat4 is initialized. These classes and resources are invisible for the entire web application. All unpacking classes and resources Under $ catalina_home / server / classes, packaged JAR files in $ Catalina_Home / Server / LIB.
Therefore, from this web application, it can be seen that the class or resource is loaded in the following warehouse, which is the following sequence:
/ Web-INF / CLASSES Your web application
/Web-inf/lib/*.jar Your web application
Your JVM bootstrap class
System Class Loader class (described above)
$ Catalina_Home / Common / Classes
$ Catalina_Home / Common / endorsed / *. Jar
$ Catalina_Home / Common / lib / *. Jar
$ Catalina_home / shared / classes
$ Catalina_home / shared / lib / *. Jar
J2SE class and expansion
In addition to the previous rules, the Web Application Class Loader will reject load from the Java language core package ("Java. *" Packages).
XML parser and JDK 1.4
Just like some other changes, JDK1.4 released a version of the JAXP APIS package and XERCES. This will affect those XML parsers who want to use their own.
In the previous Tomcat4 version, you can easily overwrite the XML parser under $ catalina_home / common / lib over the XML parser to change the parser for all web applications. However, this skill is not very effective when we run JDK1.4, because usually the Class Loader commission process always selects the implementation of the JDK.
JDK1.4 supports the external mechanism outside the JCP (I.e. Dom And Sax from W3C) by calling "Endorsed Standards Override Mechanism". He also used to update XML parsing.
When Tomcat starts a container at the command line, Tomcat is used to call the correct setting of the system by including the proper settings of the system. Therefore, you can replace the parser installed under this path, and even in JDK1.4 will also be applied.