10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Building, Packaging, and Deploying the cart Example Using NetBeans<br />

IDE<br />

Follow these instructions to build, package, and deploy the cart example to your Application<br />

Server instance using NetBeans IDE.<br />

1. In NetBeans IDE, select File→Open Project.<br />

2. In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/ejb/.<br />

3. Select the cart folder.<br />

4. Select the Open as Main Project and Open Required Projects check boxes.<br />

5. Click Open Project.<br />

6. In the Projects tab, right-click the cart project and select Undeploy and Deploy.<br />

This builds and packages the application into cart.ear, located in<br />

tut-install/javaeetutorial5/examples/ejb/cart/dist/, and deploys this EAR file to your<br />

Application Server instance.<br />

Running the cart Application Client Using NetBeans IDE<br />

To run cart’s application client, select Run→Run Main Project. You will see the output of the<br />

application client in the Output pane:<br />

...<br />

Retrieving book title from cart: Infinite Jest<br />

Retrieving book title from cart: Bel Canto<br />

Retrieving book title from cart: Kafka on the Shore<br />

Removing "Gravity’s Rainbow" from cart.<br />

Caught a BookException: "Gravity’s Rainbow" not in cart.<br />

<strong>Java</strong> Result: 1<br />

run-cart-app-client:<br />

run-nb:<br />

BUILD SUCCESSFUL (total time: 14 seconds)<br />

Building, Packaging, and Deploying the cart Example Using Ant<br />

Now you are ready to compile the remote interface (Cart.java), the home interface<br />

(CartHome.java), the enterprise bean class (CartBean.java), the client class<br />

(CartClient.java), and the helper classes (BookException.java and IdVerifier.java).<br />

1. In a terminal window, go to this directory:<br />

tut-install/javaeetutorial5/examples/ejb/cart/<br />

2. Type the following command:<br />

ant<br />

<strong>The</strong> cart Example<br />

Chapter 22 • Session Bean Examples 661

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!