Home arrow Web Authoring arrow Page 2 - Completing an EAR
WEB AUTHORING

Completing an EAR


In the second of two parts, we focus on deploying the EAR we built in the previous article. This article is excerpted from chapter three of the book JBoss at Work: A Practical Guide, written by Tom Marrs and Scott Davis (O'Reilly; ISBN: 0596007345). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
July 10, 2007
TABLE OF CONTENTS:
  1. · Completing an EAR
  2. · Deploying the EAR
  3. · Adding a DAO
  4. · Using XDoclet

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Completing an EAR - Deploying the EAR
(Page 2 of 4 )

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 code—isn’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.


blog comments powered by Disqus
WEB AUTHORING ARTICLES

- Top WordPress Plugins for Social Media
- How to Install WordPress on WAMPP
- More of the Best Wordpress Plugins for Comme...
- Top Wordpress Plugins to Fight Spam
- More of the top Drupal modules for SEO
- Top Drupal Modules for SEO
- More Top Wordpress Plugins for SEO
- Website Optimization Tips
- Backup and Restore a Drupal Website and Data...
- 5 Best Web Font Services
- Web Font Embedding Services
- Joomla Site Administration
- Create PHP Pages that Use WordPress Templates
- Top Joomla Extensions for Social Networking
- Drupal Modules for Site Navigation

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials