Exercise 11.3: Annotationless Stateless Session Bean




Exercise 11.3: Annotationless Stateless Session Bean

This exercise is a duplicate of Exercise 11.2, except that all annotations on the ProcessPayment EJB's bean and interface classes have been removed. All metadata is expressed in the ejb-jar.xml deployment descriptor.

Start Up JBoss

If you already have JBoss running, there is no reason to restart it. Otherwise, start it up as instructed in Workbook 1.

Initialize the Database

The database tables will be created when Exercise 11.3 is deployed to JBoss. If you have problems running this example, shut down JBoss and run the clean.db Ant task.

Build and Deploy the Example Programs

Perform the following steps:

  1. Open a command prompt or shell terminal and change to the ex11_3 directory created by the extraction process.

  2. Set the JAVA_HOME and JBOSS_HOME environment variables to point to where your JDK and JBoss 4.0 are installed. Examples:


    Windows:

    C:\workbook\ex11_3> set JAVA_HOME=C:\jdk1.5.0
    C:\workbook\ex11_3> set JBOSS_HOME=C:\jboss-4.0.x
    


    Unix:

    $ export JAVA_HOME=/usr/local/jdk1.5.0
    $ export JBOSS_HOME=/usr/local/jboss-4.0
    

  3. Add ant to your execution path. Ant is the build utility.


    Windows:

    C:\workbook\ex11_3> set PATH=..\ant\bin;%PATH%
    


    Unix:

    $ export PATH=../ant/bin:$PATH
    

  4. Perform the build by typing ant.

As in the earlier exercises, titan.jar is rebuilt, copied to the JBoss deploy directory, and redeployed by the application server.

Run the Client

Run the MakePayment application by invoking ant run.payment at the command prompt. Remember to set your JBOSS_HOME and PATH environment variables. This is the output:

run.payment:
     [java] Making a payment using byCash( )..
     [java] Making a payment using byCheck( )..
     [java] Making a payment using byCredit( )..
     [java] Making a payment using byCheck( ) with a low check number..
     [java] The PaymentException has not been raised because the min check number
            has been overridden in ejb-jar.xml