Java & J2EE Page 10 - Introduction to Enterprise JavaBeans |
In this section, you will look at how to deploy an EJB in the J2EE Reference Implementation (RI) and how to run the simple application client. Configuring J2EE RI On Day 2 you were asked to install and configure the J2EE RI available, free of charge, from Sun Microsystems (at http://java.sun.com/j2ee) and build a sample database for the exercises in this book. If you have not already done so go back to Day 2 and follow the instructions for installing the J2EE RI and building the Agency case study database.
There are two approaches to building and deploying a J2EE component or application using J2EE RI:
As a newcomer to J2EE, you will find it informative to use the GUI interface of deploytool for building and configuring the EAR and WAR files used to hold your EJBs, applications, and web components. As you gain more experience, you might find the speed of the asant command-line interface to be preferable. You will also find asant build files useful for scripting automated testing procedures. The disadvantage of using asant is that you will have to write the build files yourself; not to mention hand crafting all the deployment descriptors. Many developers use deploytool once to generate the basic deployment descriptors and then save these descriptors to disk for use with asant build files. That is how most of the examples for this book were developed. This section will show how to build and deploy J2EE components using deploytool before looking at the asant build files used for the Agency case study example. The directory structure for the book's example code was discussed on Day 2, but as a quick reminder, these are the subdirectories under the exercise directory for Day 4:
Remember to make sure you are running the J2EE RI server and PointBase database servers and have created the Agency database before starting this exercise. Opening the Case Study EAR File Now you are ready to run the deploytool found in the bin directory under the J2EE_HOME directory. Start a command line window in the Day04/exercise directory and enter the command: deploytool You will be presented with a graphic interface for building J2EE components. If you have not set your PATH to include the bin directory under J2EE home you will have to provide the full pathname for deploytool. Windows users can use the Start, Programs, Sun Microsystems, J2EE 1.4 SDK, Deploytool menu or run %J2EE_HOME%\bin\deploytool Solaris and Linux users should enter $J2EE_HOME/bin/deploytool In deploytool, use the File, Open menu to open the supplied agency enterprise archive (EAR) file in Day04/exercise/j2ee-ri/agency.ear. The agency application will now be displayed in the list of applications, as shown in Figure 4.2.
Figure 4.2
blog comments powered by Disqus |