Petstore1.3_01 Sample Application
Updated June 10, 2002
Table of Contents
This Sun Java (tm) System Application Server sample application document contains the
following sections:
Overview: Using the Petstore Sample Application
The Petstore1.3_01 sample application is from Java blueprints team and
it demonstrates all the J2EE1.3.1 patterns.This application is more of
a real world application and it has all the new patterns.Some of the new
patterns in this version of Petstore are:
-
Servlet Filters
-
MVC architecture for the UI
-
CMP2.0
-
MDB's (JMS Integration with EJB)
-
Java Web Start for JFC/Swing clients deployment & execution
-
Java APIs for XML
-
Component model & i18N
The complete architecture of this application can be found at the
http://java.sun.com/blueprints/code/jps11/archoverview.html
Please visit Java
Petstore Official Website for more information.
Application Setup
Petstore can be setup to run on either Point Base or Oracle Databases.
Please follow the instructions specific to your needs.
Point Base:
1. Sun Java (tm) System Application Server Comes with Point Base Database pre populated
with the data required to run Java Petstore Application.
2. Run "<appserver-install-location>/samples/petstore1.3._01/src/build.sh
setup" (Unix) or "<appserver-install-location>samples/petstore1.3._01/src/build.bat
setup" on Win2K to setup the Database related Resources for the Application
Server.
Oracle:
1. Install Oracle 9i Client or Server Software in your machine, if
you don't have the Oracle 9i server running in your local machine.
2. Configure the client software and your path environment
variable so that you can talk to your database server. In other words,
you should be able to run sqlplus from command line and be able to connect
to your database server.
3. Change Directory to <appserver-install-location>/samples/petstore1.3._01/src/sql.
4. You need to edit setupDB.sh, for your oracle
sid. Change <vortex> to your <ORACLE_SID>
5. Run this Script ./setupDB.sh. This script
creates three oracle users ias1/ias1,opc/opc
&
supplier/supplier.
6. If you choose to create your own Database user then you have
to change <appserver-install-location>/instances/<your-instance>/server.xml
and default-resource-principal in the deployment descriptors found in <appserver-install-location>/samples/petstore1.3._01/src/apps
directories. Also you need to populate these three users with with
the Application Test Data. Use the following scripts to do that petstoredb.sql,
opcdb.sql & supplierdb.sql.
7. Edit classpath variable in <appserver-install-location>/instances/<your-instance>/server.xml
to have $ORACLE_HOME/jdbc/lib/classes12.jar.
8. Execute "<appserver-install-location>/samples/petstore1.3._01/src/build.sh
setup-oracle" (Unix) or "<appserver-install-location>/samples/petstore1.3._01/src/build.bat
setup-oracle" on Win2K to setup Database related Resource for the Application
Server.
NOTE 1:
After you are done with the Database setup (Either Point Base or Oracle),
Execute "<appserver-install-location>/samples/petstore1.3._01/src/build.sh
reconfig" (Unix) or "<appserver-install-location>/samples/petstore1.3._01/src/build.bat
reconfig" on Win2K. This will apply your database configuration changes
permanently to your Application Server Instance.
NOTE 2 :
Sample Values (in bracket) to enter when executing build.sh or build.bat
for the first time are given below
admin.user=<your admin user id> (admin)
admin.password=<your admin user password> (iasadmin)
admin.host=<hostname.domainname> (localmachine.sun.com)
admin.port=<Administrator port number> (4848)
as.instance=<your appserver Instance> (server1)
db.host=<Your Database Server Name> (dbserver.sun.com)
db.port=<Database Server Port> (9092)
mail.host=<The Mailserver name> (localhost)
mail.username=<user for mail server> (petstore@sun.com)
mail.fromaddress=<your email id> (petstore@sun.com)
datasource.user=<administrator password for database> ("system"
for oracle and "pbpublic" for Point Base)
datasource.password=<the password for your database administrator>
("manager" for oracle and "pbpublic" for Point Base)
db.SID=<database server sid to which its listening> (sun-appserv-samples
for Point Base)
NOTE 3 :
After you are done with setup and deploy, you have to modify <appserver-install-location>/instances/<your-instance>/server.xml
for the three Database Connection Pools that are getting created. This
is the bug which will be addressed in the RTM Release. You need to
add the res-type for the element of jdbc-connection-pool.
After the modification, it should look like:
<jdbc-connection-pool steady-pool-size="8" max-pool-size="32"
is-isolation-level-guaranteed="true" is-connection-validation-required="false"
connection-validation-method="auto-commit" fail-all-connections="false"
datasource-classname="com.pointbase.xa.xaDataSource" res-type="javax.sql.XADataSource"
name="opcpool">
Compiling and Assembling the Application
To build and assemble the complete application
1. Compile and Assemble Web Application
Change Directory to<appserver-install-location>/samples/petstore1.3._01/src
Execute the ant target to compile all the java source by doing "./build.sh
core" (Unix) or "build.bat core" (Win2K).
Note:
If you don't want to compile the application then you can skip this
step and go to next one to deploy the ear's that comes with the Install.
Deploying the Application
-
Change Directory to<appserver-install-location>/samples/petstore1.3._01/src
-
Execute the ant target to deploy the Petstore application "./build.sh deploy"
(Unix) or "build.bat deploy" (Win2K).
-
This will Deploy the Four ".ear" files from petstore.ear, opc.ear, supplier.ear
& petstoreadmin.ear. These file are present in build directories
of the respective application directories under <appserver-install-location>/samples/petstore1.3._01/src/apps
Note 1 :
Also you can execute asadmin
to deploy application to the local application server instance:
The following is the command you can use to deploy your ".ear" files
(petstore.ear, opc.ear, supplier.ear & petstoreadmin.ear).
<appserver-install-location>/bin/asadmin
deploy -u <user-name> -w <password> -H <hostname> -p <admin
server port> --name petstore --instance <instance name> petstore.ear
Note 2 :
The deployment process involves the following operations:
Authenticates against the local application server's administrative server.
The EAR file is transferred to the administrative server.
The administrative server begins the registration process:
parses the EAR file and embedded WAR file
Explodes the bits into repository
registers the J2EE application by updating <appserver-install-location>/<your-instance>server.xml
Verifying Deployment
As an optional step, you can use the Sun Java (tm) System Application Server Administration
Tool to verify that the application has been registered. If you do not
want to verify that the application has been registered, proceed directly
to Running the Application.
To verify the registration of the application, execute iasadmin
to
look at applications deployed with a server instance:
<appserver-install-location>/bin/asadmin
list-components -u <username> -w <password> -H <host> -p <admin-port>
<server instance name>
You can see the four Java Petstore Applications (Admin, Petstore,
OPC, Supplier) listed.
Running the Sample Application
To run the application, go to the application Launch Page
http://<AppServer
hostname>:<port>/petstore/index.jsp
(For Front end)
or to the following three URLs depending on what you need to do:
http://<AppServer
hostname>:<port>/main.screen
(For Front End)
http://<AppServer
hostname>:<port>/admin
(For Admin)
http://<AppServer
hostname>:<port>/rcvr
(For Supplier)
Enter enter the Front End URL to buy pets, add items to your cart and checkout.
Enter the Supplier URL to manage the inventory. Enter the Admin URL
approve the orders over $500.00.
Note:
For Admin to work, you have to invoke http://<AppServer hostname>:<port>/admin
from Netscape on Windows Machine. If you have already installed Application
Server on PC, you don't need to do anything since Java Web Start is comes
with Application Server.
If there is no Application Server installed on your PC, you need to
download Java Web Start from http://java.sun.com/products/javawebstart.
Java Web Start has to be configured to work with JRE 1.4 for the Petstore
Application. You can go to http://java.sun.com/j2se/1.4/download.html
to download JRE 1.4 for Windows.
There are two ways to configure Java Web Start 1.0.1 working with JRE
1.4.
-
When install Java Web Start, you can specify the JRE you want to
use
-
After intall Java Web Start, you can configure it by Choosing File->Preferences->Java
to change the path of javaw.exe.
Troubleshooting and Notes
-
Check your database. All the 3 databases should be created with sample
data loaded in it
-
If you are getting jdbc connection or jms connection problem, check the
userid/passwd in the server.xml & default-resource-principal in the
deployment descriptors
-
Try deploying petstore.ear alone and try submitting an order.This EAR can
work without the other 3 EAR files.
-
Check your IMQ is properly setup and the jms resources are created. Sometimes
when the messages are not cleaned up in the queue correctly that could
cause problem.
-
Supplier URL goes to supplier database for information.
-
There is NO URL for opc and admin goes to opc database
-
The Java Web Start has to be installed correctly with JRE 1.4 version.
-
After deployment, when you restart your instance make sure that the application
is loaded correctly.
-
If you encounter problems when running the application, review the log
files at <appserver-install-location>/instances/<your-instance>/logs/server.log
for more information.
-
Petstore requires to use XADatasource. Check
if you are using XADatasource.
-
Please Make sure you have the keyfile in the
instance/config directory found in <appserver-install-location>/samples/petstore1.3._01/src
-
Try Setting <jvm-options>-Dcom.sun.sunoneserver.runtime.useunboundedpoolcache=true
</jvm-options>
-
To access the Admin URL in, you need to install
Java Web Start in your local machine. Java Web Start should point
to JRE 1.4.
Copyright
(c) 2002 Sun Microsystems, Inc. All rights reserved.