Chapter WORKBOOK 2. Exercises for Chapter 4
Chapter 4 of the EJB book walked you through a very basic example of creating one entity bean that mapped to one table and a session bean that acted as a façade to this entity bean. The entity bean was a simple Cabin entity that emulates a room on a ship. The session bean was a TravelAgent EJB that acted as the business process for interacting with the Cabin entity.
Exercise 4.1 takes the code from Chapter 4 as is and deploys it on the JBoss application server to use and run. Exercises 4.2 and 4.3 show the use of a couple of JBoss-specific annotations and XML.
Exercise 4.1: Your First Beans with JBoss
This exercise allows you to compile and deploy the code from Chapter 4 almost verbatim. You’ll see how you can build and deploy an EJB-JAR with an entity bean on the JBoss application server.
Start Up JBoss
Start up JBoss as described earlier in Workbook 1.
Initialize the Database
JBoss comes with an embedded Java database called Hypersonic SQL. All of the examples in the workbook use this database, so there is no need to install and configure any external server. Also, you do not need to create any database tables because the JBoss Java Persistence implementation can be configured to autogenerate them for you when the EJB-JAR is deployed.
Build and Deploy the Example Programs
Perform the following steps:
Open a command prompt or shell terminal and change to the ex04_1 directory created by the extraction process.
Set the
JAVA_HOME
andJBOSS_HOME
environment ...
Get Enterprise JavaBeans 3.0, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.