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 6.1 runtime follow the hierarchy shown in the following figure.
Note that this is not a Java inheritance hierarchy, but a delegation hierarchy. In the delegation design, a classloader delegates classloading to its parent before attempting to load a class itself. If the parent classloader can't 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 searches 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 Elements
The following table describes Sun Java System Web Server 6.1 classloaders. The left column lists the classloaders, and the right column lists descriptions of those classloaders and the files they examine.
Table 6–3 Sun Java System Web Server 6.1 Classloaders
Classloader |
Description |
---|---|
The Bootstrap Classloader loads the JDK classes. Only one instance of this classloader exists in the entire server. |
|
The System Classloader loads the core Sun Java System Web Server 6.1 classes. It is created based on the classpathprefix, serverclasspath, and classpathsuffix attributes of the <JAVA> element in the server.xml file. The environment classpath is included if envclasspathignored="false" is set in the <JAVA> element. Only one instance of this classloader exists in the entire server. If any changes are made to these attributes/classes, the server must be restarted for the changes to take effect. For more information about the <JAVA> element in server.xml, see the Sun Java System Web Server 6.1 SP8 Administrator’s Configuration File Reference. |
|
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 existence of these directories is optional; if they don't exist, the Common Classloader is not created. If any changes are made to these classes, the server must be restarted for the changes to take effect. |
|
The Web Application Classloader loads the servlets and other classes in a specific web application. That is, 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 Elements An instance of this classloader is created for each web application. If dynamic reloading is enabled, any changes made to these attributes/classes are reloaded by the server without the need for a restart. For more information, see Dynamic Reloading of Web Applications |
|
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, seejsp-config |