Hot-Deploying to JBoss
Problem
You want to deploy a new EAR or WAR file to JBoss.
Solution
Copy a new EAR to the deploy
directory within
the server environment that JBoss was started with.
Discussion
JBoss provides a simple mechanism to hot deploy: simply copy a new
EAR file to the deploy
directory within the
server environment that JBoss was started with. This process is
different from Tomcat; Tomcat requires the use of the Manager
application. JBoss simply keeps tabs on the appropriate
deploy
directory, and when something new is
discovered, it’s deployed. If an old application
exists then it is removed.
Here is an Ant target
named
deploy
that copies an EAR file to
JBoss, which is automatically installed:
<target name="deploy" depends="ear"
description="Builds and deploys the project to JBoss.">
<copy file="${dir.build}/${ear.file}" todir="${dir.jboss.deploy}"/>
</target>
The same target could be duplicated to copy a WAR file, too. The
todir
attribute is extremely important. The Ant
property dir.jboss.deploy
is defined as a
well-known location within JBoss. Specifically, JBoss scans a
directory for new deployed applications within the server environment
that JBoss was started with. JBoss has
three main default server
environments:
- minimal
The bare minimum needed to start JBoss 3.x. This environment contains only logging, JNDI, and a URL deployment scanner for hot deploying. An EJB container, JMS, and other services are not available.
- default
The default server environment. This environment ...
Get Java Extreme Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.