Exploding Deployments


We're sure you can see the power of being able to access the temporary directory JBoss uses to hold expanded archives. If you find yourself wanting to use this feature a lot, JBoss supports the notion of an exploded deployment. Instead of deploying your application in its normal archived form, you can deploy it as a fully expanded directory and save JBoss the trouble of copying it out to the temporary directory.

How do I do that?

The exploded WAR directory has the exact same structure as a regular WAR file. Our build file could easily be modified to build to a WAR directory, but since we have a WAR file already made, we'll just use that.

From the deploy directory, we'll expand quote.war into a new WAR directory using the jar command:

     [deploy]$ mkdir quote2.war     [deploy]$ cd quote2.war/     [quote2.war]$ jar xvf ../quote.war       created: META-INF/     extracted: META-INF/MANIFEST.MF     extracted: quote.jsp       created: WEB-INF/       created: WEB-INF/lib/     extracted: WEB-INF/lib/jstl.jar     extracted: WEB-INF/lib/standard.jar     extracted: WEB-INF/web.xml     [quote2.war]$ ls     META-INF        WEB-INF         quote.jsp 


Note: You won't find a copy of the application in tmp/deploy when you deploy an exploded archive. It's just not needed.

If you check the console log, you'll see the application has been deployed. Since the new application is deployed as quote2.war, you'll access it at a slightly different URL than before: http://localhost:8080/quote2/quote.

You can edit quote.jsp in the live application, just as you did in the last lab. What is more interesting is that you can edit the deployment descriptors now. When JBoss detects a change to the web.xml file, it will redeploy the whole application. Try adding an additional servlet mapping for quote.jsp and watch the application redeploy.

What just happened?

We discovered how to deploy applications on JBoss in exploded form. This isn't limited to WAR files. Any J2EE archive can be deployed in exploded form. A nested archive, such as a WAR file inside of an EAR file, for example, can be deployed as nested directories. JBoss will always monitor the topmost J2EE deployment descriptor (application.xml, in the case of the EAR file example) to know when to redeploy the application.


Note: Nesting archives is called Russian Doll Packaging in JBoss. JBoss supports arbitrary nesting of archives. Any package type can contain any other. If you want an EAR file inside of another EAR file, for example, JBoss is happy to oblige.


JBoss. A Developer's Notebook
JBoss: A Developers Notebook
ISBN: 0596100078
EAN: 2147483647
Year: 2003
Pages: 106

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net