DBA Tips Archive for Oracle

  


Configuring the Pet Store Web Application Demo for OC4J

by Jeff Hunter, Sr. Database Administrator


Introduction

The Pet Store Demo is a popular J2EE web application written by Sun Microsystems. Oracle provides an "OC4J-Ready Pet Store Demo" that contains configuration and modifications in order to work with the OC4J server. This allows users to be able to execute the Pet Store demo with minimal effort. This document provides the steps necessary to download and install the Pet Store Web Application Demo to OC4J Standalone 9.0.3.

Downloading the OC4J-Ready Version of the Pet Store Demo

The Pet Store application can be downloaded from OTN at: http://otn.oracle.com/sample_code/tech/java/oc4j/content.html. This file will be names either petstore.zip or jps112.zip and will contain the Pet Store Demo version 1.1.2. You will notice also that the OC4J-Ready version contains an annotated version along with pre-configured OC4J XML files.

Installing the Pet Store Demo

Before installing the Pet Store Demo, you will need to have a working Oracle database and an OC4J installation. Keep in mind that this installation should be used for testing and demonstration purposes only and not in a production environment. One other note (for those of you familiar with Sun's J2EE reference implementation) this example uses the Oracle database as opposed to the default Cloudscape database.

Installation Steps

  1. Download the Pet Store application from OTN using the notes from the above section.

  2. Copy the file petstore.zip to the $OC4J_HOME/j2ee/home/applications directory. Unzip the petstore.zip file. It contains the following files:

    • steps.html - Steps on how to deploy the Pet Store demo.
    • petstore.ear - The Pet Store demo application.
    • config.zip - OC4J server XML configuration files.

  3. Copy the file config.zip to a temporary directory. Unzip the config.zip file to retrieve the server.xml, default-web-site.xml, and data-sources.xml files. Place these files in the $OC4J_HOME/j2ee/home/config directory. If you have already modified the existing XML files, merge these files with the existing files.

  4. Edit $OC4J_HOME/j2ee/home/config/data-sources.xml to point to your database by replacing the host, port, and sid in the url attribute for the data source in this file, as follows:
    url="jdbc:oracle:thin:@<host>:<port>:<sid>"
  5. Create in your Oracle database the user estoreuser, and grant this user the proper privileges. You can create the user and grant privileges through the following commands:
      SQL> CREATE USER estoreuser IDENTIFIED BY estore
        2  DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
    
      User created.
    
      SQL> GRANT connect, resource TO estoreuser;
    
      Grant succeeded.

  6. Start the OC4J server by executing:
      java -jar oc4j.jar -verbosity 10

  7. Execute the Pet Store application in your browser, where the default port is 8888:
      http://<your_machine_name>:8888/estore

  8. The above URL should successfully bring up the Java™ Pet Store Demo. Near the bottom of the page, click on the link labeled "Enter the store".

  9. The application will check for the existence of certain database tables. If they are not found, you will be directed to the "Java Pet Store Demo Database Populate" page. Click on the link "Install tables" in the upper header of the page. The application will then check to see which database server is being used as its Data Source. You should choose "Install Oracle tables".

  10. After creating the required tables in Oracle, you should click "Return to Java Petstore Demo" to return to the Pet Store home page.

  11. To start using the Pet Store Demo, click on the "Enter the store" link (again). This will (finally) start the "Java™ Pet Store Demo Web Application".


Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Thursday, 05-Dec-2002 00:00:00 EST
Page Count: 8801