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.

A <strong>Java</strong> <strong>EE</strong> ApplicationThat Uses the JMS API with an Entity<br />

968<br />

Employee ID: 26<br />

Name: Jack Verdon<br />

Equipment: Pager<br />

Office number: 20<br />

Waiting for 3 message(s)<br />

New hire event processed:<br />

Employee ID: 27<br />

Name: Fred Tudor<br />

Equipment: Pager<br />

Office number: 51<br />

Waiting for 2 message(s)<br />

New hire event processed:<br />

Employee ID: 28<br />

Name: Fred Martin<br />

Equipment: Desktop System<br />

Office number: 141<br />

Waiting for 1 message(s)<br />

New hire event processed:<br />

Employee ID: 29<br />

Name: Mary Stuart<br />

Equipment: Pager<br />

Office number: 238<br />

<strong>The</strong> output from the message-driven beans and the entity class appears in the server log,<br />

wrapped in logging information.<br />

For each employee, the application first creates the entity and then finds it. You may see<br />

runtime errors in the server log, and transaction rollbacks may occur. <strong>The</strong> errors occur if both<br />

of the message-driven beans discover at the same time that the entity does not yet exist, so they<br />

both try to create it. <strong>The</strong> first attempt succeeds, but the second fails because the bean already<br />

exists. After the rollback, the second message-driven bean tries again and succeeds in finding<br />

the entity. Container-managed transactions allow the application to run correctly, in spite of<br />

these errors, with no special programming.<br />

You can run the application client repeatedly.<br />

Undeploy the application after you finish running the client. To undeploy the application,<br />

follow these steps:<br />

1. Click the Services tab.<br />

2. Expand the Servers node.<br />

3. Expand the Application Server node.<br />

4. Expand the Applications node.<br />

5. Expand the Enterprise Applications node.<br />

6. Right-click clientmdbentity and choose Undeploy.<br />

To remove the generated files, right-click the clientmdbentity project and choose Clean.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

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

Saved successfully!

Ooh no, something went wrong!