Java
  Home arrow Java arrow Page 13 - Introduction to Enterprise JavaBeans
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Introduction to Enterprise JavaBeans
By: Martin Bond
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 38
    2004-06-21

    Table of Contents:
  • Introduction to Enterprise JavaBeans
  • Types of EJB and Common Uses of EJBs
  • What's in an EJB?
  • The Home Interface
  • Implementing the Home Interface
  • Verifying an EJB
  • The EJB-JAR File
  • How Do I Deploy an EJB?
  • Disposing of the EJB
  • Using the J2EE Reference Implementation
  • Examining the Case Study Application
  • Verifying the Case Study Application
  • Managing J2EE RI Applications
  • Troubleshooting the Case Study Application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Introduction to Enterprise JavaBeans - Managing J2EE RI Applications
    (Page 13 of 14 )

    You can manage J2EE RI applications using any of the following interfaces:

    • deploytool

    • The asadmin command line utility

    • The Admin Console web application (http://localhost:4848/asadmin/)

    Using deploytool you can obtain a list of deployed objects by selecting the localhost:4848 entry under Servers in the left pane and a list of deployed components will be displayed, as shown in Figure 4.12.

    bond

    Figure 4.12
    Managing J2EE Deployed Objects with deploytool.

    You can start, stop and undeploy an object using the appropriate buttons on this dialog.

    Should you need to retrieve a client JAR file from a deployed application you can do this by selecting your application, clicking on the Client Jar... button and specifying a directory location on the popup dialogue window.

    If you prefer to work from the command line, then you can use the asadmin utility. To deploy an application you use the asadmin deploy command. To deploy the example EAR file you have been viewing use the command

    asadmin deploy --user admin --force j2ee-ri/agency.ear

    You need to specify the name of your administrative user and the EAR filename; the --force option forces a redeployment if the application has already been deployed. You will be prompted for the administrative password unless you have stored this password in a configuration file, or as an environment variable, as described on Day 2 under the installation instructions for the J2EE SDK.

    If you want to return the client JAR file when deploying an application use a command such as:

    asadmin deploy --user admin --force --retrieve j2ee-ri j2ee-ri/agency.ear

    The --retrieve option requires the name of the directory for the client JAR file; the client JAR filename is derived from the application name as described previously.

    You can retrieve the client JAR file for a previously deployed application using the get-client-stubs command to asadmin as follows:

    asadmin get-client-stubs --user admin --appname agency j2ee-ri

    This command requires the application name (--appname option) and the target directory for the client JAR file.

    As discussed on Day 2 asadmin will provide useful help messages when an invalid command is entered. And, you can always use the --help option to get more information. For example:

    asadmin -help
    asadmin deploy -help
    admin get-client-subs --help

    Finally, you can administer deployed applications using the J2EE RI Admin Console at http://localhost:4848/asadmin/. Select the Applications, Enterprise Applications option in the left pane to deploy and undeploy applications as shown in Figure 4.13.

    You can only stop, start, deploy and undeploy applications using the Admin Console interface; you cannot return client JAR files.

    bond

    Figure 4.13
    Using the J2EE RI Admin Console to Manage J2EE Components.

    Case Study asant Build Files

    As an alternative to using deploytool to build and deploy J2EE components, you can use Apache Ant (sometimes called Jakarta Ant) to assemble the EAR or WAR files from the constituent components. Ant is a Java-based, open source, automated build tool that is quickly becoming the de facto standard build tool for Java programmers. A version of Apache Ant, called asant, is included with the J2EE SDK and example asant build files are supplied with the J2EE 1.4 Tutorial examples. A discussion on writing the Ant build files required to assemble a J2EE archive is outside the scope of this book, but the online Ant documentation at http://ant.apache.org/manual/index.html gives a good introduction to writing build files. Alternatively you could check out the book Extreme Programming with Ant from SAMS Publishing.

    On the accompanying Web site, asant build files have been provided to compile and package the EAR and WAR files used throughout this book. As described in Day 2, each working directory contains a build.xml file that defines the asant build targets appropriate for the directory.

    The build.xml file in the Day04/exercise directory will build, deploy, and run the simple client example. In order to help you use asant with the case study, each build.xml file contains a help build target that will tell you which targets you can use for each directory, this is also the default asant target. Run the following command from the Day04/exercise directory to see what targets are available:

    asant

    To remove all the temporary files and then compile and build the case study from scratch, use the command

    asant clean build

    The generated agency.ear file is stored in the build subdirectory and is kept separate from the supplied agency.ear file in the j2ee-ri directory. The various deployment descriptors used to build the EAR file are kept in the dd/agency subdirectory.

    You can verify the built application using the command

    asant verify

    The verification results from this command are stored in the file build/agency.ear.txt.

    To deploy the case study from the build directory, use the command

    asant deploy

    This will return the client JAR as build/agencyClient.jar. To run the simple client example, use the command

    asant run

    You should see the following output:

    ...
    appclient:
       [echo] (build) appclient.bat -client agencyClient.jar -name SimpleClient
       [exec] Welcome to: J2EE in 21 Days Job Agency
       [exec] Customer list: J2EE in 21 Days Job Agency
       [exec] abraham
       [exec] alfred
       [exec] george
       [exec] winston

       [exec] Done

    To undeploy the agency example use

    asant undeploy

    If you want to use deploytool to build the EAR file but work at the command line to verify, deploy and run the examples, then you can use the following commands.

    Verify the deploytool maintained agency.ear file in the j2ee-ri sub-directory with

    asant verify-j2ee-ri

    Deploy and return the j2ee-ri/agencyClient.jar file with

    asant deploy-j2ee-ri

    Run the application client (in the j2ee-ri sub-directory) using

    asant run-j2ee-ri

    To undeploy the agency example you still use

    asant undeploy

    This chapter is from Teach Yourself J2EE in 21 Days, second edition, by Martin Bond et. al. (Sams, 2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy this book now.

    More Java Articles
    More By Martin Bond


     

       

    JAVA ARTICLES

    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway