You can download the example code for the exercises from http://www.oreilly.com/catalog/entjbeans4/workbooks/index.html. Exercises that require a database will use JBoss’s default embedded database. Consequently, no additional database setup is required. This workbook includes an Appendix that shows you how to configure JBoss to use a different database, if you want to.
The example code is organized as a set
of directories, one for each exercise (Figure 21-5). You’ll find the code
of each exercise in the src/main
subdirectory
and the configuration files in src/resources
.
To build and run the exercises, you’ll use the
Ant
tool. A
build.xml
is
provided for each exercise. It contains the Ant configuration needed
to compile the classes, build the EJB JAR, deploy it to JBoss, and
run the client test applications. For this reason, the Ant tool is
provided with the exercises and can be found in the
ant
directory.
You can find out more about Ant at the Apache Jakarta web site http://jakarta.apache.org/ant/.
For the Ant scripts to work correctly, first set some environment variables in the shells you will use to run the exercises:
The JAVA_HOME
environment variable must point to
where your JDK is installed.
The JBOSS_HOME
environment variable must point to
where JBoss is installed.
The directory containing the Ant scripts must be in your path.
Depending on your platform, you’ll have to execute commands like these:
Windows:
C:workbookex04_1> set JAVA_HOME=C:jdk1.4.2
C:workbookex04_1> set JBOSS_HOME=C:jboss-4.0 C:workbookex04_1> set PATH=..antin;%PATH%
|
Unix:
$ export JAVA_HOME=/usr/local/jdk1.4.2
$ export JBOSS_HOME=/usr/local/jboss-4.0 $ export PATH=../ant/bin:$PATH
|
In each chapter, you’ll find detailed instructions on how to build, deploy, and run the exercises using Ant.