Using Java™ Pet Store with Oracle

This scenario assumes that you are familiar with the basics of application assembly and deployment.

Before you begin

The Pet Store application and supporting files are located in the installableApps/petstore directory:
Several incompatibilities exist between WebSphere Application Server V4.0 and V1.1.2 of the petstore.ear file, available from Sun Microsystems. The petstore.ear file provided with WebSphere Application Server V4.0 is already modified for you. The following list summarizes the changes made:

Assembling the Application

Configure the petstore.ear file with Oracle and enable mail confirmation:
  1. Make a backup copy of the petstore.ear file.
  2. Start the Application Assembly Tool (AAT):
  3. Load the new copy of the petstore.ear file.
  4. Expand petstore > EJB Modules > Customer Component > Entity Beans > TheOrder and click Environment Entries.
  5. Change the value of the ejb/order/OrderDAOClass parameter to com.sun.j2ee.blueprints.customer.order.dao.OrderDAOOracle.
  6. Click Apply.
  7. Expand petstore > EJB Modules > Petstore EJB Component > Session Beans > TheShoppingClientController and click Environment Entries.
  8. Change the value of the sendMailConfirmation parameter from false to true.
  9. Click Apply.
  10. Save your configuration by clicking File > Save.
  11. Exit AAT by clicking File > Exit.

Deploying the Pet Store Application

This section describes the steps for implementing the Pet Store application.

Creating and Populating the Database

Locate the ps_oracle.sql file in the installableApps\petstore directory. This .sql file creates the required tables and populates them with data.
  1. Log on to the Oracle Database Server as an Oracle user.
  2. Copy the ps_oracle.sql file to the Oracle Database Server.
  3. Set the ORACLE_SID environment variable:
  4. From the command line, change to the directory containing the ps_oracle.sql file.
  5. Sign on to Oracle SQLPlus with DBA authority.
  6. Issue the following command at the SQL prompt: @ps_oracle.sql
    The @ is required.
  7. Exit SQLPlus.

Administering the J2EE Resources

  1. Start the WebSphere Application Server.
  2. Start the WebSphere Advanced Administrative Console.
  3. Add the Pet Store Data Source:
  4. Add the Pet Store Mail Session:
    Add a JavaMail session to the default mail provider. Pet Store only sends outgoing mail, so only mail transport needs configuration.
  5. Enable application-level visibility so that .wars and EJB .jars can find classes in other .wars and EJB .jars:

Installing the Application

  1. Right-click on Enterprise Applications and click Install Enterprise Application.
  2. Select Install Application and click Browse. Locate the petstore.ear file and click Open.
  3. Type petstore for the Application name and click Next.
  4. Click Next on the Mapping Users to Roles window. You will map the users to roles later.
  5. Click Next on the Mapping EJB RunAs Roles to Users window.
  6. Verify that the JNDI Names are correct on the Binding Enterprise Beans to JNDI Names window, and click Next.
  7. Verify that the JNDI Names are correct on the Mapping EJB References to Enterprise Beans window, and click Next.
  8. Verify that the JNDI Names are correct on the Mapping Resource References to Resources window, and click Next.
  9. Click Next on the Specifying the Default Datasource for EJB Modules window.
  10. Click Next on the Specifying Datasource for Individual CMP Beans window.
  11. Click Next on the Selecting the Virtual Hosts for Web Modules window.
  12. Verify Default Server is selected as the Application Server for each of the modules on the Selecting the Application Server window, and click Next.
  13. Click Finish on the Completing the Application Installation Wizard window.
  14. Click No when prompted to regenerate code, and wait for the application to finish installing.
  15. Click OK at the Command Completed Successfully dialog.
  16. Expand Nodes > Your Node. Right-click on Your Node and select Regen Webserver Plugin.
  17. Expand Nodes > Your Node > Application Servers. Right-click on Default Server and click Stop, if the server has already started.
  18. Right-click on Default Server and click Start.

Running the Application

  1. Expand Enterprise Applications, right-click on petstore, and click Start.
  2. Run the Pet Store Sample.
      Using the back button on your browser is not recommended with Pet Store, and can cause problems. To return to a previous page in the application, use the links in the Pet Store application. For example, to return to the Main page, click on the Pet Store banner. See the official Pet Store documentation from Sun, for further details.

    Enable cookies in your browser to support Pet Store security.

Uninstalling the Pet Store Application

  1. From the WebSphere Application Server Administrative Console:
  2. Drop the Pet Store database:
  3. Remove the Datasource and MailSession from the WebSphere Application Server Administrative Console:
  4. Stop the WebSphere Application Server.