Author:tcoleman@autowares.com>
<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 most recently deployed using the JBoss-Jetty package, JBoss-2.4.0_Jetty-3.1.RC8-1. If you use the JBoss-Jetty package, you will have to add Pet Store DB Pools to the jboss.jcml file in the jboss/conf/jetty directory.
The Pet Store had previously been deployed using a JBoss 2.4 BETA configured to use Embedded Tomcat 3.2.2. The specific release used was JBoss 2.4 BETA Rel_2_4_0_23.
Both deployments were on a RH Linux 6.2 system using the Sun 1.3 jdk.
Please post your experiences with deploying the Pet Store in JBoss to the jboss-user mailing list.
Initializing the Database. The Pet Store application should automatically build required database tables the first time the Pet Store application is started. The latest database schema is slightly different from the earlier release, so you may encounter problems if you have an existing Pet Store database from a previous installation. When tring to determine the initial status of the database, this conflict may cause one of the drop commands to fail, and the application will not create the required tables. If this is the case, you may need to manually drop all existing tables before deploying the Pet Store for the first time. It may help to turn off your browser cache while building the tables.
The Admin Client. We need JBoss deployment descriptors for the Admin application. If you have successfully deployed the Admin application using JBoss, please post them to one of the Forums or to the jboss-user mailing list.
Pet Store Security. The current release of the Pet Store handles security at the application level. It does require that you configure JBoss or Tomcat security services.
You can get the source from Sun's J2EE Download Page. It's in the "J2EE Blueprints" package. Download the 1.1.2 version. Unpack it anywhere. The root directory of the Pet Store demo is referred to below as $PETSTORE.
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 current patch file, jps112-01.zip is currently available in the documentation files section of the manual.
You need a servlet container to run the Java Pet Store. If you're using the JBoss-Jetty or JBoss-Tomcat releases, the server is preconfigured.
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.
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 jps112-01.zip 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 unzip jps1.1.2-01.zip
Rebuild the Pet Store application.
Run build.sh 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
The JBoss Pet Store patch file includes the file jboss.jcml. This file defines Pet Store DB Pools for JBoss 2.4 using Cloudscape on 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 the appropriate DB pools for your database. See ??? for details
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
Start Cloudscape.
Copy your DB driver JAR to the lib/ext directory of your JBoss installation ($JBOSS_HOME).
For Cloudscape, copy client.jar and RmiJdbc.jar to the lib/ext directory.
Copy tools.jar from the J2 SDK to the lib/ext directory of your JBoss installation ($JBOSS_HOME).
Start JBoss and copy the new petstore.ear to the deploy directory. You should see JBoss deploy the Pet Store EJBs.
Point your browser to http://your-server-name.your-domain:8080/estore to start the Pet Store.