Java
  Home arrow Java arrow Page 12 - 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Introduction to Enterprise JavaBeans - Verifying the Case Study Application
    (Page 12 of 14 )

    The J2EE RI comes with a verifier utility that you can use to validate the contents of an EAR file. The verifier can be run from the command line or it can be invoked from the Tools, Verify J2EE Compliance... menu option from within deploytool.


    Note - The authors used J2EE SDK 1.4 released in November 2003 for the development of the code used in this book. Unfortunately they encountered problems when running the verifier from within deploytool. Specifically running the verifier against this simple example incorrectly reported a problem with a missing JNDI name for the jdbc/Agency resource reference. Running the command line verifier against the same EAR file did not report a problem. You are urged to double check any verification problems reported from deploytool by using the command line verifier utility. For the example case study you can do this manually using the command

    verifier j2ee-ri/agency.ear

    from within the Day04/exercise directory. Alternatively use the supplied asant build files (see section "Case Study asant Build Files") and enter

    asant verify-j2ee-ri



    Caution - Micosoft Windows users should be aware that there is a standard Windows 2000/XP utility called verifier. If you have not put the %J2EE_HOME%\bin directory at the start of your PATH environment variable you will have to use the command

    %J2EE_HOME"\bin\verifier

    to run the J2EE SDK verifier. The supplied asant build files for the case study use the fully qualified file name and therefore do not require the PATH to be modified.


    You are advised to run verifier on all new EAR files or when changes have been made to any of the files composing an EJB. To illustrate the use of the verifier, Figure 4.10 shows the errors produced by a simple mistake in coding the AgencyBean.java class; in this case the ejbCreate() method was mistakenly defined as create().

    bond

    Figure 4.10
    verifer errors from a missing ejbCreate() method in AgencyBean.java.

    Running the verifier from within deploytool produces a list of failed tests or a brief "There were no failed tests" message. Selecting each failed test in turn will supply further information about the test. In Figure 4.10 the message indicates the following:

     [agency.AgencyBean] does not properly declare at least one ejbCreate() method

    A simple mistake can cause the failure of many tests, so do not be alarmed if you see a large number of test failures.


    Caution - The verifier tool works from the on-disk EAR file and not from the in-memory copy created by deploytool. Make sure you save your application using the File, Save menu option before running verifier.


    After you have written, packaged up your application, and verified the application contents, you are ready to deploy.

    Deploying the Case Study Application

    You can deploy the server-side components of the agency application using deploytool. To deploy the agency application, select the agency application item (indicated by a blue diamond under the Applications folder in the explorer area in the left-hand panel), and select the Tools, Deploy... menu. This will display the initial deployment screen shown in Figure 4.11.

    bond

    Figure 4.11
    Deployment dialog for the Agency case study.

    You will need to provide the administrative username and password (admin and password if you installed the J2EE SDK as described on Day 2). You should also check the Return Client Jar box on the dialogue to ensure your Application Client Jar file is downloaded from the J2EE server. Accept the default location for the client JAR file (this will be the same directory as the EAR file).

    Click on OK to proceed with deploying your application and then click Close on the popup window when the deployment completes.


    Note - If your J2EE component has already been deployed, the existing version will be undeployed, and then the new version will be deployed. When redeploying an application the J2EE RI will not return a new client JAR file even if asked it to do so. You will either have to do this manually or explicitly undeploy and redeploy your application as described in the section "Managing J2EE RI Applications."


    This is the point at which things might go wrong. If you are using the software from the Web site, you should have no trouble, but if you are developing your own example then you might come across problems at this stage. The "Troubleshooting Deployment" section, later on, discusses problems that might occur at deployment. If something does go wrong, study the information in the deployment progress window and also look at the J2EE console window for additional, more detailed information.

    Running the Application Client

    After you have successfully deployed the server-side components of the application under the J2EE RI, you can run the simple application client to test the application.

    To run an application client you must have obtained the client-side JAR file from the deployed application. You did this when you deployed the application by checking the Return Client Jar... box on the deployment popup window. You can also obtain the client JAR file using either deploytool, the Web-based Admin Console, or the command line asadmin utility as described in the following section "Managing J2EE RI Applications."

    The client JAR file contains all the client and EJB class files as well as the RMI stub files required to run the application client.

    You run a J2EE RI application client using the appclient command (from the J2EE SDK bin directory). The appclient requires the name of the client JAR as its single –client parameter. Assuming you have followed the deployment process described in the previous section, your returned client JAR file will be in the Day02/exercise/ j2ee-ri directory and called agencyClient.jar.

    You can run your deployed client as follows (your command entry is shown in bold):

    appclient -client j2ee-ri/agencyClient.jar
    Welcome to: J2EE in 21 Days Job Agency
    Customer list: J2EE in 21 Days Job Agency
    abraham
    alfred
    george
    winston

    Done

    The client JAR file is always named after the application by appending Client.jar to the name of the application.

    Congratulations, you have just deployed and run your first J2EE application. If the client fails to run, then look at the errors on the console window or in the domains/domain1/logs/server.log file in the J2EE SDK home directory for more information.

    If you want to examine the simple Web Application you deployed with the EJB, then browse to the URL http://localhost:8000/webagency. You will look at Web Applications in detail on Days 12, 13, and 14.

    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 4 hosted by Hostway