background image

Running the cart Application

<< Deploying the cart Example | Undeploying the cart Example >>
<< Deploying the cart Example | Undeploying the cart Example >>

Running the cart Application

Building, Packaging, and Deploying the cart Example Using Ant
Now you are ready to compile the remote interface (Cart.java), the home interface
(CartHome.java), the enterprise bean class (CartBean.java), the client class
(CartClient.java), and the helper classes (BookException.java and IdVerifier.java).
1. In a terminal window, go to this directory:
tut-install/javaeetutorial5/examples/ejb/cart/
2. Type the following command:
ant
This command calls the default target, which builds and packages the application into an
EAR file, cart.ear, located in the dist directory.
3. Type the following command:
ant deploy
cart.ear
will be deployed to the Application Server.
Running the cart Application Client Using Ant
When you run the client, the application client container injects any component references
declared in the application client class, in this case the reference to the Cart enterprise bean. To
run the application client, perform the following steps.
1. In a terminal window, go to this directory:
tut-install/javaeetutorial5/examples/ejb/cart/
2. Type the following command:
ant run
This task will retrieve the application client JAR, cartClient.jar and run the application
client. cartClient.jar contains the application client class, the helper class
BookException
, and the Cart business interface.
This is the equivalent of running:
appclient -client cartClient.jar
3. In the terminal window, the client displays these lines:
[echo] running application client container.
[exec] Retrieving book title from cart: Infinite Jest
[exec] Retrieving book title from cart: Bel Canto
The cart Example
The Java EE 5 Tutorial · September 2007
664