JBoss.org Community Documentation
The previous discussion of the core class loading components introduced the custom UnifiedClassLoader3
and UnifiedLoaderRepository3
classes that form a shared class loading space. The complete class loading picture must also include the parent class loader used by UnifiedClassLoader3
s as well as class loaders introduced for scoping and other specialty class loading purposes. Figure 3.5, “A complete class loader view” shows an outline of the class hierarchy that would exist for an EAR deployment containing EJBs and WARs.
The following points apply to this figure:
System ClassLoaders : The System ClassLoaders node refers to either the thread context class loader (TCL) of the VM main thread or of the thread of the application that is loading the JBoss server if it is embedded.
ServerLoader
: The ServerLoader node refers to the a URLClassLoader
that delegates to the System ClassLoaders and contains the following boot URLs:
All URLs referenced via the jboss.boot.library.list
system property. These are path specifications relative to the libraryURL
defined by the jboss.lib.url
property. If there is no jboss.lib.url
property specified, it defaults to jboss.home.url + /lib/
. If there is no jboss.boot.library
property specified, it defaults to jaxp.jar
, log4j-boot.jar
, jboss-common.jar
, and jboss-system.jar
.
The JAXP JAR which is either crimson.jar
or xerces.jar
depending on the -j
option to the Main
entry point. The default is crimson.jar
.
The JBoss JMX jar and GNU regex jar, jboss-jmx.jar
and gnu-regexp.jar
.
Oswego concurrency classes JAR, concurrent.jar
Any JARs specified as libraries via -L
command line options
Any other JARs or directories specified via -C
command line options
Server
: The Server node represent a collection of UCLs created by the org.jboss.system.server.Server
interface implementation. The default implementation creates UCLs for the patchDir
entries as well as the server conf
directory. The last UCL created is set as the JBoss main thread context class loader. This will be combined into a single UCL now that multiple URLs per UCL are supported.
All UnifiedClassLoader3s : The All UnifiedClassLoader3 node represents the UCLs created by deployers. This covers EARs, jars, WARs, SARs and directories seen by the deployment scanner as well as JARs referenced by their manifests and any nested deployment units they may contain. This is a flat namespace and there should not be multiple instances of a class in different deployment JARs. If there are, only the first loaded will be used and the results may not be as expected. There is a mechanism for scoping visibility based on EAR deployment units that we discussed in Section 3.2.2.4.2, “Scoping Classes”. Use this mechanism if you need to deploy multiple versions of a class in a given JBoss server.
EJB DynClassLoader
: The EJB DynClassLoader
node is a subclass of URLClassLoader
that is used to provide RMI dynamic class loading via the simple HTTP WebService. It specifies an empty URL[]
and delegates to the TCL as its parent class loader. If the WebService is configured to allow system level classes to be loaded, all classes in the UnifiedLoaderRepository3
as well as the system classpath are available via HTTP.
EJB ENCLoader
: The
EJB ENCLoader
node is a URLClassLoader
that exists only to provide a unique context for an EJB deployment's java:comp
JNDI context. It specifies an empty URL[]
and delegates to the EJB DynClassLoader
as its parent class loader.
Web ENCLoader
: The Web ENCLoader
node is a URLClassLoader that exists only to provide a unique context for a web deployment's java:comp
JNDI context. It specifies an empty URL[]
and delegates to the TCL as its parent class loader.
WAR Loader
: The
WAR Loader
is a servlet container specific classloader that delegates to the Web ENCLoader as its parent class loader. The default behavior is to load from its parent class loader and then the WAR WEB-INF
classes
and lib
directories. If the servlet 2.3 class loading model is enabled it will first load from the its WEB-INF
directories and then the parent class loader.
In its current form there are some advantages and disadvantages to the JBoss class loading architecture. Advantages include:
Classes do not need to be replicated across deployment units in order to have access to them.
Many future possibilities including novel partitioning of the repositories into domains, dependency and conflict detection, etc.
Disadvantages include:
Existing deployments may need to be repackaged to avoid duplicate classes. Duplication of classes in a loader repository can lead to class cast exceptions and linkage errors depending on how the classes are loaded.
Deployments that depend on different versions of a given class need to be isolated in separate EARs and a unique HeirarchicalLoaderRepository3
defined using a jboss-app.xml
descriptor.