Deploying the Pet Store 1.1.1 Demo in JBoss

Author:Tom Coleman <>


The Pet Store sample application (demo) is a relatively robust, well-documented demonstration of J2EE technology and concepts. It implements MVC (Model-View-Controller) architecture.

The Pet Store demo can allow developers to gain familiarity with J2EE concepts including application portability, a key J2EE design objective.

The Pet Store has been successfully deployed in JBoss PRE 2.1 configured to use Embedded Tomcat and Tomcat 3.2.1/Apache using Sun 1.3 jdk on Linux. The steps provided below apply to JBoss PRE 2.1 since 21st January 2001.

Outstanding Deployment Issues

Please post your experiences with deploying the Pet Store in JBoss to the jboss-user mailing list.

The security adapter

The Pet Store implements non-portable security code that works only with the J2EE RI (Reference Implementation) server.

The non-portable code is contained in the J2eeSecurityAdapter class. The JBoss Pet Store patch replaces this class with a JBossSecurityAdapter class that implements the SecurityAdapter interface.

The steps below change the value for securityAdapterClassName in the Pet Store application to use JBossSecurityAdapter.

See the /docs/security.html page in the Pet Store demo for more information.

Adding new users

In order to add new users, you have to configure Tomcat to use a JDBCRealm. See below for details.

The Admin Client

We still need JBoss specific Deployment descriptors for the Admin client application. Please post them to the mailing list if you have them.

Original contributers

  • Mike Lueders, Richard Gyger - Focus Technologies

  • Scott Stark

  • Anatoly Ackerman

  • Tom Coleman

  • Aaron Mulder

Installation & Configuration

  1. Download the Pet Store

    You can get the source from Sun's J2EE Download Page. It's in the "J2EE Blueprints" package. Download the 1.1.1 version. Unpack it anywhere. The root directory of the Pet Store demo is referred to below as $PETSTORE.

  2. Download the JBoss Pet Store patch file

    Running the Pet Store demo in JBoss requires several minor changes to deployment files in the Pet Store application (.ear) file. The patch is currently available in the file section of the manual, it is named

    Copy the patch file to a temporary directory and unzip it. The patch contains a zip file that patches the Pet Store demo.

  3. Configure JBoss to use Embedded Tomcat

    You need a servlet container to run the petstore. These instructions use Tomcat 3.2.1. You can either use a bundled binary JBoss + Tomcat, or see the instructions to configure JBoss to use Embedded Tomcat in the section called “Tomcat and JBoss - A Full J2EE Stack”.

  4. Select a Database

    The Pet Store demo uses the Cloudscape database by default.

    The Pet Store demo theoretically should work with just about any JDBC compliant database. However, to avoid problems with SQL syntax doing a Product Search, use Cloudscape if at all possible.

  5. Rebuild the Pet Store application (petstore.ear)

    The following step overwrites several files in the Pet Store application sources. You may want to make a separate copy of the JBoss version of the Pet Store.

    This step adds the file jboss-web.xml to the WEB-INF directory in petstore.war, modifies the serverType in the web.xml file of that directory to identify the JBoss server to the application, and modifies the application.xml file in the META-INF directory of petstore.ear.

    • Copy the file to the root directory ($PETSTORE) of your Pet Store distribution. Change to this directory and unzip the file.

      Note: This will overwrite the original web.xml file.

      cd $PETSTORE

    • Rebuild the Pet Store application.

      Run or build.bat in the $PETSTORE/src/petstore/src/build directory.

      The result is a new petstore.ear in the $PETSTORE/src/petstore/build directory.

      This is the file you deploy by copying it to $JBOSS_HOME/deploy

  6. Add DB Pools to JBoss

    The JBoss Petstore patch file includes the file jboss.jcml. This file defines Pet Store DB Pools for Cloudscape using port 1098.

    Cloudscape uses port 1099 by default. JBoss uses port 1099 for JNDI.

    If you will be using a different database, you will need to define DB pools appropriate for your database. See Chapter 3., JDBC for details

  7. Prepare the Database

    Modify the Cloudscape startup command to use port 1098.

    You do this by adding -port port_number. For example:

    java ... RmiJdbc.RJJdbcServer -port 1098 COM.cloudscape.core.JDBCDriver

    Whichever product you're using, create a database or instance or schema (the terminology varies) and then run the appropriate script to populate it.

    Start Cloudscape.

  8. Add JARS to JBoss

    Copy your DB driver JAR to the lib/extdirectory of your JBoss installation ($JBOSS_HOME).

    Copy tools.jar from the J2 SDK to the lib/ext directory of your JBoss installation ($JBOSS_HOME).

    For Cloudscape, copy cloudscape.jar and RmiJdbc.jar to the lib/ext directory.

  9. Add Tomcat JDBCRealm

    Find the following code in the Tomcat server.xml file and comment it out.

      debug="0" />

    Add the following code just below the code you commented out.

      connectionPassword="estore" />

    Make sure the JbossRealm interceptor follows the JDBCRealm definition.

      className="" />

    Change to the $PETSTORE directory and run the dbrealm script to set up the default Pet Store user.

  10. Modify the Tomcat Users file

    The patch contains a tomcat-users.xml file that adds the default Pet Store user. You can copy this file to your $TOMCAT_HOME/conf directory, or add the following line to your existing tomcat-users.xml file.

    You don't need to do this if you configure a JDBCRealm as described above.

    <user name = "j2ee"  password = "j2ee"  roles = "customer" />
  11. Start JBoss

    Start JBoss and copy the new petstore.ear to the deploy directory. You should see JBoss deploy the Pet Store EJBs.

  12. Run the Pet Store

    Point your browser to http://your-server-name.your-domain:8080/estore to start the Pet Store.