Section 3.4. Deploying the EAR


3.4. Deploying the EAR

Let's make sure that the WAR files from the previous chapters don't end up conflicting with our EAR file. Delete jaw.war from the deploy directory before moving on. Now we're ready to drop in our newly created EAR file.

Deploying an EAR by hand is no different than deploying a WAR by hand. Copy jaw.ear to $JBOSS_HOME/server/default/deploy. Your JBoss console should let you know that it was deployed successfully, as in Example 3-6.

Example 3-6. JBoss console output showing a successful EAR deployment
 22:37:55,659 INFO  [EARDeployer] Init J2EE application:       file:/Library/jboss-4.0.1/server/default/deploy/jaw.ear 22:37:55,853 INFO  [TomcatDeployer] deploy, ctxPath=/jaw,       warUrl=file:/Library/jboss-4.0.1/server/default/tmp/deploy/       tmp25111jaw-ear.ear-contents/webapp.war/ 22:37:56,159 INFO  [EARDeployer] Started J2EE application:       file:/Library/jboss-4.0.1/server/default/deploy/jaw-ear.ear 

Automated Deployments Using Ant

Ant allows you to do far more than simply compile and bundle up your Java application. It has tasks that let you create and delete directories and copy files to a local subdirectory or a remote server by using ftp or scp. Using tasks like exec, rexec, or sshexec, you can even remotely start and stop JBoss.

It's not hard to imagine completely automating the deployment process with an Ant script. But just because you can do something doesn't always mean you should.

Automating deployment to a test server certainly will help speed up your development iterations. But deployments to a production server should be taken a bit more seriously. Upgrading a production application is something that should be done deliberately, and in our opinion, should be done by hand.

If you provide an Ant task to deploy your application to a production server, you almost certainly guarantee that you will invoke it accidentally at the most inopportune time.

Since we point at a test server for this book, we've provided a convenient couple of Ant targets to deploy your EAR. To do a hot deploy, make sure that you have the $JBOSS_HOME environment variable set, and then simply type ant deploy. The Ant task will copy the EAR file to the correct location for you.

If you want to do a cold deploy, shut down JBoss, type Ant cleandeploy, and then start JBoss back up again. The cleandeploy target will delete the existing EAR file and several temporary directories. Running cleandeploy against a running JBoss instance will cause bad things to happen, so make sure that JBoss is not running before invoking it.


Visit http://localhost:8080/jaw to confirm that the application was indeed deployed and still works as expected. Yes, this application doesn't look or behave any differently than the one in the Web chapter. But we added hundreds of lines of new codeisn't that the true measure of a successful J2EE project? (Only kidding....)

In all seriousness, we haven't added any new functionality that the user would notice, but we have set the stage for easy future growth and maximum flexibility. Knowing that the other tiers are coming up soon, these changes will allow you to incorporate the new technology with minimal effort.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

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