Article
Enterprise JavaBeans, A Primer: Part 3, A Tour of the Java Pet Store
Starting the Database
The Pet Store requires a database to be installed and populated. The reference implementation provides a free database called Cloudscape. You must start the Cloudscape database before you deploy the Pet Store application. On a UNIX or Linux system, open a shell window and type:
cd <J2EE_HOME>/bin
cloudscape -start
On a Windows system, open a command window and type:
cd <J2EE_HOME>\bin
cloudscape.bat –start
Starting the Application Server
Now, you must start the application server provided by the reference implementation. This will also start the EJB container provided by the reference implementation. On a UNIX or Linux system, open a shell window and type:
cd <J2EE_HOME>/bin
j2ee -verbose
On a Windows system, open a command window and type:
cd <J2EE_HOME>\bin
j2ee.bat -verbose
Building and Deploying the Application
Once you've installed everything, started the database and started the application server, you must build and deploy the Pet Store application. To build the application on a UNIX or Linux system, open a shell window and type:
cd <PETSTORE_INSTALL_DIR>/src/apps/admin/src
sh build.sh
cd <PETSTORE_INSTALL_DIR>/src/apps/opc/src
sh build.sh
cd <PETSTORE_INSTALL_DIR>/src/apps/petstore/src
sh build.sh
cd <PETSTORE_INSTALL_DIR>/src/apps/supplier/src
sh build.sh
On a Windows system, open a command window and type:
cd <PETSTORE_INSTALL_DIR>\src\apps\admin\src
build.bat
cd <PETSTORE_INSTALL_DIR>\src\apps\opc\src
build.bat
cd <PETSTORE_INSTALL_DIR>\src\apps\petstore\src
build.bat
cd <PETSTORE_INSTALL_DIR>\src\apps\supplier\src
build.bat
After you build the application, you'll find a .ear file in each of the following directories:
<PETSTORE_INSTALL_DIR>/src/apps/admin/build<PETSTORE_INSTALL_DIR>/src/apps/opc/build<PETSTORE_INSTALL_DIR>/src/apps/petstore/build<PETSTORE_INSTALL_DIR>/src/apps/supplier/build
Now you must deploy the .ear files of the Pet Store application. You can use the deploytool to deploy the .ear files. To deploy the application .ear files using deploytool., on a UNIX or Linux system, open a shell window and type:
cd <J2EE_HOME>/bin
sh deploytool.sh
On a Windows system, open a command window and type:
cd <J2EE_HOME>\bin
deploytool.bat
Once the deploytool is running, you will see a window similar to this:
In the deploytool, select the File -> Open menu item for each .ear file of the Pet Store application. A new node will be created in the navigation (left) pane of the deploytool for each .ear file you open. Now, select the node in the navigation pane and click the “Deploy…" menu item. Accept the default options for each pane of the deploy wizard and select the “Next" button until you see the “Finish" button. When the “Finish" button appears, click it. A diagnostic window appears, showing you the progress of the deploy process. When the deploy process is finished, close the dialog and open the next .ear file.
After building and deploying the application, you can start to use it.
Running the Pet Store Application
Using a browser, go to the following URL:
http://localhost:8000/petstore
The first time you run the Pet Store, you will need to create a new user before making a purchase.
- Click the Sign-In link on the home page.
- Fill out the form titled, "I would like to sign up for an account", and click Create New Account.
- Enter your account information, and click Submit.