Java Pet Store Tutorial

 
 
The Java Pet Store is a popular J2EE example application in the J2EE Blueprints series, created by Sun Microsystems. It models an e-commerce application where customers can purchase pets online using a Web browser. The purpose of this application is to demonstrate the capabilities of the J2EE platform and is written for learning purposes (for example to illustrate the many different design patterns on various part of J2EE). It is not coded for performance and is not intended for performance benchmarks.

The Java Pet Store 1.3.2 follows the J2EE 1.3 specs which is a set of related specifications and can be seen as a single standard for implementing and deploying enterprise applications. Java Pet Store 1.3.2 demonstrates the following:
  • How to use Java Server Pages (jsp).
  • How to use Java Servlets.
  • How to use Enterprise JavaBeans (EJB).
  • How to use Java Message Service (JMS).
  • How to use JSP Standard Tag Library (JSTL).
  • How to use the Java API for XML-based RPC (JAX-RPC).
  • How to use SOAP.
  • How to exchange and process XML-based documents.
  • How to develop flexible, scalable, cross-plaform enterprise applications.
  • How to use the Java BluePrints guidelines and patterns.
  • Illustrate basic usage of J2EE technology with current best practices.
The Pet Store application comes with full source code and documentation, and the latest release can be downloaded from: http://java.sun.com/blueprints/code/index.html#java_pet_store_demo

More information about Pet Store can be found at:
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/
sample-app/sample-app1.3.1a3.html


ATTENTION:
The petstore-1_3_2.zip is no longer available at the http://java.sun.com/blueprints/ site.
Sun.com discourage people from investing time in learning it since its old, and instead encourage developers to learn the newer material.

However there are several companies using the old BluePrints Web Application Framework (WAF) where the petstore 1.3.2 demo is based on. Download the petstore-1_3_2.zip file.








Installing Java Pet Store 1.3.2



Information
In version 1.3.2 webservices are removed, some bugs are fixed and minor cleanup has been done compared to version 1.3.1_02.

Operating system used
Windows XP Home Edition Version 5.1 SP 2

Software prerequisites
Java 2 Standard Edition SDK (J2SE SDK), v1.4.1 or higher
Java 2 Enterprise Edition SDK (J2EE SDK), v1.3.1

Procedure
  1. Download and unzip petstore-1_3_2.zip.
    The directory (example) C:\Tools\petstore1.3.2 will be referred as <petstore.home>.

  2. The J2EE SDK should be configured (installs and configure message services and database resources) to run the Pet Store application:
       cd <petstore.home>
       setup.bat


  3. The Pet Store requires a database to be installed. The J2EE SDK provides a free database called Cloudscape. To start Cloudscape:
       cd %J2EE_HOME%\bin
       cloudscape -start
    If all went well, you should see: [RmiJdbc] RmiJdbcServer bound in rmi registry
  4. The J2EE SDK provides an application server (including an EJB container). To start the J2EE server:
       cd %J2EE_HOME%\bin
       j2ee.bat -verbose
    If all went well, you should see: J2EE server startup complete.
    To verify if the J2EE server is running: http://localhost:8000/index.html

    J2EE server default page



  5. Deploy the Pet Store application consisting of four ear files:
    • opc.ear
    • petstore.ear
    • petstoreadmin.ear
    • supplier.ear
    on the application server:
       cd <petstore.home>
       setup.bat deploy


    Note 1: The ear files are deployed on the application server at:
    %J2EE_HOME%\repository\<machine name >\applications\

    Note 2: The four ear files which were deployed were all taken from <petstore.home>. If you have build all the source code, the newly created ear files are not placed in <petstore.home>.

  6. If you wish to undeploy the Pet Store application from the application server:
       cd %J2EE_HOME%\bin
       deploytool


    The Application Deployment tool is displayed.
    Select a deployed object one at the time and press the undeploy button.


    J2SDKEE1.3.1 deploytool