Show Table of Contents
5.5. JBoss Deployer Architecture
JBoss has an extensible deployment architecture that allows one to incorporate components into the bare JBoss JMX microkernel. The
MainDeployer is the deployment entry point. Requests to deploy a component are sent to the MainDeployer and it determines if there is a subdeployer capable of handling the deployment, and if there is, it delegates the deployment to the subdeployer. We saw an example of this when we looked at how the MainDeployer used the SARDeployer to deploy MBean services. Among the deployers provided with JBoss are:
- AbstractWebDeployer: This subdeployer handles web application archives (WARs). It accepts deployment archives and directories whose name ends with a
warsuffix. WARs must have aWEB-INF/web.xmldescriptor and may have aWEB-INF/jboss-web.xmldescriptor. - EARDeployer: This subdeployer handles enterprise application archives (EARs). It accepts deployment archives and directories whose name ends with an
earsuffix. EARs must have aMETA-INF/application.xmldescriptor and may have aMETA-INF/jboss-app.xmldescriptor. - EJBDeployer: This subdeployer handles enterprise bean jars. It accepts deployment archives and directories whose name ends with a
jarsuffix. EJB jars must have aMETA-INF/ejb-jar.xmldescriptor and may have aMETA-INF/jboss.xmldescriptor. - JARDeployer: This subdeployer handles library JAR archives. The only restriction it places on an archive is that it cannot contain a
WEB-INFdirectory. - RARDeployer: This subdeployer handles JCA resource archives (RARs). It accepts deployment archives and directories whose name ends with a
rarsuffix. RARs must have aMETA-INF/ra.xmldescriptor. - SARDeployer: This subdeployer handles JBoss MBean service archives (SARs). It accepts deployment archives and directories whose name ends with a
sarsuffix, as well as standalone XML files that end withservice.xml. SARs that are jars must have aMETA-INF/jboss-service.xmldescriptor. - XSLSubDeployer: This subdeployer deploys arbitrary XML files. JBoss uses the XSLSubDeployer to deploy
ds.xmlfiles and transform them intoservice.xmlfiles for theSARDeployer. However, it is not limited to just this task. - HARDeployer: This subdeployer deploys hibernate archives (HARs). It accepts deployment archives and directories whose name ends with a
harsuffix. HARs must have aMETA-INF/hibernate-service.xmldescriptor. - AspectDeployer: This subdeployer deploys AOP archives. It accepts deployment archives and directories whose name ends with an
aopsuffix as well asaop.xmlfiles. AOP archives must have aMETA-INF/jboss-aop.xmldescriptor. - ClientDeployer: This subdeployer deploys J2EE application clients. It accepts deployment archives and directories whose name ends with a
jarsuffix. J2EE clients must have aMETA-INF/application-client.xmldescriptor and may have aMETA-INF/jboss-client.xmldescriptor. - BeanShellSubDeployer: This subdeployer deploys bean shell scripts as MBeans. It accepts files whose name ends with a
bshsuffix.
The MainDeployer, JARDeployer and SARDeployer are hard coded deployers in the JBoss server core. All other deployers are MBean services that register themselves as deployers with the MainDeployer using the
addDeployer(SubDeployer) operation.
The
MainDeployer communicates information about the component to be deployed the SubDeployer using a DeploymentInfo object. The DeploymentInfo object is a data structure that encapsulates the complete state of a deployable component.
When the
MainDeployer receives a deployment request, it iterates through its registered subdeployers and invokes the accepts(DeploymentInfo) method on the subdeployer. The first subdeployer to return true is chosen. The MainDeployer will delegate the init, create, start, stop and destroy deployment life cycle operations to the subdeployer.
5.5.1. Deployers and ClassLoaders
Deployers are the mechanism by which components are brought into a JBoss server. Deployers are also the creators of the majority of UCL instances, and the primary creator is the MainDeployer. The MainDeployer creates the UCL for a deployment early on during its init method. The UCL is created by calling the DeploymentInfo.createClassLoaders() method. Only the topmost
DeploymentInfo will actually create a UCL. All subdeployments will add their class paths to their parent DeploymentInfo UCL. Every deployment does have a standalone URLClassLoader that uses the deployment URL as its path. This is used to localize the loading of resources such as deployment descriptors. Figure 5.20, “An illustration of the class loaders involved with an EAR deployment” provides an illustration of the interaction between Deployers, DeploymentInfos and class loaders.

Figure 5.20. An illustration of the class loaders involved with an EAR deployment
The figure illustrates an EAR deployment with EJB and WAR subdeployments. The EJB deployment references the
lib/util.jar utility jar via its manifest. The WAR includes classes in its WEB-INF/classes directory as well as the WEB-INF/lib/jbosstest-web-util.jar. Each deployment has a DeploymentInfo instance that has a URLClassLoader pointing to the deployment archive. The DeploymentInfo associated with some.ear is the only one to have a UCL created. The ejbs.jar and web.warDeploymentInfos add their deployment archive to the some.ear UCL classpath, and share this UCL as their deployment UCL. The EJBDeployer also adds any manifest jars to the EAR UCL.
The
WARDeployer behaves differently than other deployers in that it only adds its WAR archive to the DeploymentInfo UCL classpath. The loading of classes from the WAR WEB-INF/classes and WEB-INF/lib locations is handled by the servlet container class loader. The servlet container class loaders delegate to the WAR DeploymentInfo UCL as their parent class loader, but the server container class loader is not part of the JBoss class loader repository. Therefore, classes inside of a WAR are not visible to other components. Classes that need to be shared between web application components and other components such as EJBs, and MBeans need to be loaded into the shared class loader repository either by including the classes into a SAR or EJB deployment, or by referencing a jar containing the shared classes through a manifest Class-Path entry. In the case of a SAR, the SAR classpath element in the service deployment serves the same purpose as a JAR manifest Class-Path.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.