Classloaders

Sun Java System Web Server 7.0 classloaders help you determine where and how you can position
supporting JAR and resource files of your modules and applications.

In a Java Virtual Machine (JVM), the classloaders dynamically load a
specific Java class file needed for resolving a dependency. For example, when
an instance of java.util.Enumeration needs to be created,
one of the classloaders loads the relevant class into the environment.

Classloaders in the Sun Java System Web Server 7.0 runtime follow the hierarchy shown
in the following figure.

Figure 9–1 Classloader Runtime Hierarchy

This hierarchy is a delegation hierarchy not a Java inheritance hierarchy.
In the delegation design, a classloader delegates classloading to its parent
before attempting to load a class itself. If the parent classloader cannot
load a class, the findClass()method is called on the classloader
subclass. In effect, a classloader is responsible for loading only the classes
not available to the parent.

The exception is the web application classloader, which follows
the delegation model in the Servlet specification. The web application Classloader
looks in the local classloader before delegating to its parent. You can make
the web application Classloader delegate to its parent first by setting delegate="true" in the class-loader element of the sun-web.xml file.
For more information, see Classloader Element.

The Bootstrap Classloader loads the JDK classes. Only one instance of
this classloader exists in the entire server.

System

The System Classloader loads the core Sun Java System Web Server 7.0 classes. It is created
based on the class-path-prefix, server-class-path,
and class-path-suffix attributes of the <jvm/> element
in the server.xml file.

The environment classpath is included if env-classpath-ignored="false" is set in the <jvm/> element. Only one instance
of this classloader exists in the entire server.

If any changes are made to these attributes or classes, the server must
be restarted for the changes to take effect.

The Common Classloader loads classes in the instance_dir/lib/classes directory, followed by JAR and ZIP files in the instance_dir/lib directory. The directories
are optional. If they don't exist, the Common Classloader is not created.
If any changes are made to these classes, restart the server.

Web Application

The Web Application Classloader loads the servlets and other classes
in a specific web application from WEB-INF/lib and WEB-INF/classes and from any additional classpaths specified in the extra-class-path attribute of the class-loader element in sun-web.xml. For more information, see Classloader Element.

An instance of this classloader is created for each web application.
If dynamic reloading has been enabled, any changes made to these attributes
or classes are reloaded by the server without the need for a restart. For
more information, see Dynamic Reloading of Web Applications

JSP

The JSP Classloader loads the compiled JSP classes of JSPs. An instance
of this classloader is created for each JSP file. Any changes made to a JSP
are automatically detected and reloaded by the server unless dynamic reloading
of JSPs has been disabled by setting the reload-interval property
to -1 in the jsp-config element of the sun-web.xml file. For more information, see jsp-config Element.