DBA Tips Archive for Oracle
Configuring the Pet Store Web Application Demo for OC4J
by Jeff Hunter, Sr. Database Administrator
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
jps112.zipand 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.
- Download the Pet Store application from OTN using the notes from the above section.
- Copy the file
petstore.zipto the $OC4J_HOME/j2ee/home/applications directory. Unzip the
petstore.zipfile. 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.
- Copy the file
config.zipto a temporary directory. Unzip the
config.zipfile to retrieve the
data-sources.xmlfiles. Place these files in the
$OC4J_HOME/j2ee/home/configdirectory. If you have already modified the existing XML files, merge these files with the existing files.
$OC4J_HOME/j2ee/home/config/data-sources.xmlto point to your database by replacing the host, port, and sid in the
urlattribute for the data source in this file, as follows:url="jdbc:oracle:thin:@<host>:<port>:<sid>"
- 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.
- Start the OC4J server by executing:java -jar oc4j.jar -verbosity 10
- Execute the Pet Store application in your browser, where the default port is 8888:http://<your_machine_name>:8888/estore
- 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".
- 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".
- After creating the required tables in Oracle, you should click "Return to Java Petstore Demo" to return to the Pet Store home page.
- 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 email@example.com.
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.