The Apache Tomcat Servlet/JSP Container

Apache Tomcat 5.5 Servlet/JSP 容器

Jaxmao Logo

Apache Tomcat Configuration Reference

The Loader Component

Introduction

The Loader element represents the web application class loader that will be used to load Java classes and resources for your web application. Such a class loader must follow the requirements of the Servlet Specification, and load classes from the following locations:

  • From the /WEB-INF/classes directory inside your web application.
  • From JAR files in the /WEB-INF/lib directory inside your web application.
  • From resources made available by Catalina to all web applications globally.

A Loader element MAY be nested inside a Context component. If it is not included, a default Loader configuration will be created automatically, which is sufficient for most requirements.

For a more in-depth description of the class loader hierarchy that is implemented by Catalina, see the ClassLoader HowTo.

在下面的描述中使用变量名$CATALINA_HOME来代指Tomcat5所安装的目录地址,这是一个基础目录(base directory),其他的相关路径由它而派生。不过,如果你已经把Tomcat设置成多个体实例(multiple instances),并且设立了一个$CATALINA_BASE目录,那么你就应使用$CATALINA_BASE而不是$CATALINA_HOME作为参照。

Attributes
Common Attributes

Loader的所有实现支持下列属性:

AttributeDescription
className

Java class name of the implementation to use. This class must implement the org.apache.catalina.Loader interface. If not specified, the standard value (defined below) will be used.

delegate

Set to true if you want the class loader to follow the standard Java2 delegation model, and attempt to load classes from parent class loaders before looking inside the web application. Set to false (the default) to have the class loader look inside the web application first, before asking parent class loaders to find requested classes or resources.

reloadable

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

NOTE - The value for this property will be inherited from the reloadable attribute you set on the surrounding Context component, and any value you explicitly set here will be replaced.

Standard Implementation

The standard implementation of Loader is org.apache.catalina.loader.WebappLoader. It supports the following additional attributes (in addition to the common attributes listed above):

AttributeDescription
backgroundProcesssorDelay

The number of seconds between checks for modified classes and resources, if reloadable has been set to true.

See the general documentation for this parameter at Host Container.

loaderClass

Java class name of the java.lang.ClassLoader implementation class to use. If not specified, the default value is org.apache.catalina.loader.WebappClassLoader.

useSystemClassLoaderAsParent

If no parent classloader is specified, should the system classloader be used? The default of true mantains backwards compatibility with previous releases however most users will want to set this to false to obtain the parent classloader from the associated container.

This attribute will not be present in Tomcat 6 where the Loader API has changed and the parent class loader is always obtained from the associated container.

Nested Components

No components may be nested inside a Loader element.

Special Features
Logging

A loader is associated with the log category based on its classname.


Copyright © 1999-2006, Apache Software Foundation