JavaTM Pet Store 1.1.2 on iPlanet
iPlanetTM Application Server Samples

Updated June 12, 2001

If you already went through the deployment process of Pet Store, you can run the application by clicking here.

Java Pet Store 1.1.2 is the Sun J2EE sample application that demonstrates many facets of the J2EE specification. See the Architectural Overview document for more information regarding the design and implementation of this popular J2EE application. The Blueprints area of http://java.sun.com offers many resources on the design of J2EE applications.

Implementation of Pet Store on iPlanet enables you to develop an understanding of the value added features provided by the iPlanet J2EE platform. After you deploy and run the application on iPlanet, you will be able to explore load balancing, clustering and other aspects of the iPlanet platform that enhance the portable Java Pet Store application.

Changes Made to the Sun's Java Pet Store describes the changes made to Sun's Pet Store application in order to run it on iPlanet Application Server.

Setting Up the Environment

Getting Started includes a checklist of pre-requisites for deploying sample applications to iPlanet.

Configuring the Database describes how to register the JDBC data sources for the Pet Store application.

Deploying and Running the Pet Store Application
Select one of two approaches to deploying the application:
Command Line-based Deployment describes how to manually register the Pet Store application in iPlanet using a Command Line Interface (CLI). This is the fastest means of deploying the Pet Store to the application server.

GUI-based Deployment describes how to use the iPlanet Deployment Tool to import and deploy the Pet Store application.

Running the Application describes how to start the application, navigate through it and how to troubleshoot in the event of problems.

Known Issues describes known problems with the sample

Further Exploration

Modifying the Deployment Decriptor describes how to modify the application to use a database other than PointBase.

Recompiling and Assembling the Application demonstrates the use of Ant to recompile the sources and rebuild the WAR and EJB modules and the overall EAR file of the application.

Deploying the Administrative Application describes how to deploy and run the administrative application made available in Java Pet Store 1.1.2.

Deploying the Mailer Mini Application describes how to deploy and run the mailer mini application made available in Java Pet Store 1.1.2.

Clustering the Pet Store Application describes how to take advantage of the application server's load balancing and clustering features.

Performance Testing the Pet Store Application describes how to tweak the application configuration and application server settings to maximize performance of the application.

Enabling Order Confirmation via E-mail explains how to configure e-mail based notification of events via iPlanet's Java Mail interface.

Exercising the Excel and Staroffice Demos describe how to use popular spreadsheet applications to view order information via HTTP access to the Pet Store application.


Changes Made to Sun's Java Pet Store

To take advantage of the PointBase database included with iPlanet Application Server, several minor enhancements were made to the Java Pet Store sample application. Since the slightly modified Java Pet Store application is bundled as part of iPlanet Application Server, you do not need to download Pet Store separately from the Sun Microsystems web site.

Support for PointBase
Since the Java Pet Store Application from Sun Microsystems does not support PointBase as a database, iPlanet enhanced the application to allow PointBase to be supported. The affected files are:

PointBase is the default database used in the copy of Java Pet Store included in iPlanet Application Server.

Request Mappings XML File Modified
Since iPlanet has not yet certified the Japanese language support in this sample, the reference to the Japanese language screen definitions was removed from the following file:

petstore/src/docroot/WEB-INF/xml/

<screen-definition url="/WEB-INF/xml/ja/screendefinitions.xml" language="ja_ JP"/>

URL Modified in populate.jsp

The populate.jsp file was modified to work around a <welcome-file-list> issue in the application server. A "/" was added to just after the getContextPath() call:

<td> <a href="<%=request.getContextPath()%>/" ><font color="white">Return to Java Petstore Demo</font></a></td>

Ant build.xml Enhancements
The Ant-based build.xml files were enhanced to support iPlanet-specific EJB compiler and deployment functions.


Configuring the Database

iPlanet supports and has tested deployment of Java Pet Store on iPlanet against PointBase, Oracle and Sybase databases. By default, PointBase is configured as the default database. Other databases supported by the application server should work in conjunction with Pet Store, but iPlanet has not tested these combinations. Please use the PointBase, Oracle and Sybase sample configuration files as the basis for using other databases.

In Java Pet Store 1.1.2 database population occurs automatically during the first interaction with the application. In previous versions of the application separate setup steps were required to populate the database. Although the database is populated automatically, you are still required to setup the JDBC database driver and JDBC datasources used by the application.

Running Pet Store with PointBase

Since the JDBC driver for the preinstalled PointBase database server has already been registered during installation of the iPlanet Application Server, you do not need to install and register the driver separately. When running Pet Store with PointBase, all you need to do is register the datasource.

Running Pet Store with Oracle or Sybase

To use a database other than PointBase, you will need to follow these steps:

  1. Register JDBC Driver
  2. Identify RDBM User
  3. Register JDBC Datasources
  4. Modify Deployment Decriptor

1. Register JDBC Driver

For installations that will not use PointBase, this section describes how to register an underlying database driver with iPlanet in the event that a driver was not registered during installation of the application server. The following instructions address only the registration of the database client driver. A subsequent section of this document describes how to register the JDBC data sources required by the sample.

You have the option of using either the iPlanet Type 2 JDBC driver or an external driver such as the Oracle Type 4 JDBC driver. A Type 4 driver is easier to configure in that it requires only a JAR file containing the RDBM client classes. Type 2 drivers require native client libraries.

Register Third Party JDBC Driver

You have the option of using either command line utilities or the Application Server Administrative GUI to define JDBC drivers and their associated data sources. The following instructions address command line definition of the JDBC driver. See the iPlanet Application Server SP3 Release Notes for a complete description of registering third party JDBC drivers in iPlanet.

UNIX:

Execute the db_setup.sh script to register a third party JDBC driver.

a) Enter the application server installation root directory:

Please enter the iAS installation root directory:
/usr/iplanet/ias6
b) Select option 2, Third Party JDBC Drivers
Do you want to use third party JDBC drivers or native drivers.
1. iPlanet Type 2 Drivers
2. Third Party Drivers
To accept the default shown in brackets, press the Enter key.

Select the component you want to install (1/2) [1]:

c) Enter a logical name for the driver. This name will be supplied in the next step when configuring the JDBC datasource XML file.
For example, for Oracle Type 4, the sample uses "ora-type4"

For example, for Sybase jConnect, the sample uses "jconnect".

d) Enter the driver class name.
For example, for Oracle, "oracle.jdbc.driver.OracleDriver"

For example, for Sybase, "com.sybase.jdbc2.jdbc.SybDriver"

e) Enter the fully qualified path of the driver JAR or ZIP file.
For example, forOracle, "<ORACLE_HOME>/jdbc/lib/classes12_01.zip"

For example, for Sybase, "<jConnect install>/classes/jconn2.jar"

f) Enter the path for the driver's native libraries. Optional, applies to Type 2 drivers only.

g) Restart the application server using the iascontrol kill and iascontrol start commands. Refer to the Getting Started section for more information. You must use the kill subcommand to ensure that the Java Engines (kjs') are completely stopped.

h) The next step is to identify an RDBMS user under which you will create and populate the application tables.

Windows:
Execute the jdbcsetup.exe program to register a third party JDBC driver.

a) Enter a logical name for the driver. This name will be supplied in the next step when configuring the JDBC datasource XML file.

For example, for Oracle Type 4, the sample uses "ora-type4"

For example, for Sybase jConnect, the sample uses "jconnect".

b) Enter the driver class name.
For example, for Oracle, "oracle.jdbc.driver.OracleDriver"

For example, for Sybase, "com.sybase.jdbc2.jdbc.SybDriver"

c) Enter the fully qualified path of the driver JAR or ZIP file.
For example, forOracle, "<ORACLE_HOME>/jdbc/lib/classes12_01.zip"

For example, for Sybase, "<jConnect install>/classes/jconn2.jar"

d) Enter the path for the driver's native libraries. Optional, applies to Type 2 drivers only.

e) Restart the application server using either the Application Server Administrative Tool or the iascontrol stop and iascontrol start commands. Refer to the Getting Started section for more information.

f) The next step is to identify an RDBMS user under which you will create and populate the application tables.

Register iPlanet Type 2 JDBC Driver

Determine if the iPlanet Type 2 Driver is Registered
On Windows, the application server automatically detects whether or not drivers for any of the supported databases are available. If a suitable driver is present, the driver will be automatically registered during installation of the application server.

On UNIX, if during installation, either "Typical" or "Express" options were selected, JDBC database drivers will not be registered with the application server. If you are unsure as whether or not the client driver was registered, use the application server administrative tool to determine the drivers registered with the application server.

  1. Start the application server administrative tool:
  2. install_dir/ias/bin/ksvradmin
  3. If the application server instance is not listed automatically, connect to your application server instance by selecting File->New->Server. Click on Localhost to specify the default connection settings. Enter the iPlanet Application Server administrator's password and click on OK.
  4. Click on the Database button and expand the server name (default name of iAS1) to see the database driver settings.
  5. If you see a red X on the client driver entry of interest, then you need to run the db_setup.sh script to register the native client driver with the application server. Go to the next section to register the driver.
Register iPlanet Type 2 Driver if Necessary
For UNIX, if the driver has not been registered (you see the red X in the Admin Tool), then you must use the db_setup.sh command to register the driver with iPlanet.

UNIX: Database Driver Registration

  1. Ensure that your user ID is the same as the one used to install the application server.
  2. Execute the database driver registration script:
  3. install_dir/ias/bin/db_setup.sh
  4. Follow the instructions to register the iPlanet Type 2 native client driver. The default iPlanet installation root directory is /usr/iplanet/ias6.
  5. For the Pet Store sample, you do not need to register a Resource Manager. (Resource Manager setup is required only in support of distributed and possibly heterogeneous transactions relying on the transaction manager built into iPlanet Application Server).
  6. Restart the application server using either the Application Server Administrative Tool or the iascontrol stop and iascontrol start commands. Refer to the Getting Started section for more information.
  7. After you've registered the driver, you can use the Admin Tool to verify that the native driver entry no longer shows a red X and that the client library and other settings are accurate
Proceed to the next section to identify an RDBMS user under which you will create and populate the application tables.

2. Identify an RDBMS User

You should ensure that you have an RDBMS user defined for the sample application. You can use either an existing RDBMS user or define a new RDBMS user for the sample application. This RDBMS user will own the tables created for the sample application. The following example shows how to create a new user called estore using the Oracle SQL Plus utility. It is strongly recommended that a user such as estore be used to create the Pet Store database tables. This approach will help to avoid confusion with similar table names used in other applications.

To define a new Oracle user:

  1. Use SQL Plus to define an Oracle user name (e.g. estore).

  2. SQL > create user estore identified by estore;

    Where the first estore is the user name and the second estore is the password.
  3. Grant connect, resource, and dba privileges to the estore Oracle user.

  4. SQL> grant connect, resource, dba to estore identified by estore;

Now that you've identified a user for the Pet Store application tables, the next step is to populate the tables.

3. Register JDBC Datasources

Depending on the JDBC driver type you've selected to use, you'll modify a pair of pre-built datasource XML files and register these files through the iasdeploy CLI. Your modifications to the XML files will specify the database connection properties that are unique to your environment. Sample XML files are included for both Oracle and Sybase.

Modify Sample Datasource XML Files
Modify the supplied datasource XML files to suit your driver and database connection requirements. The logical driver name you assigned to your third party driver in the driver registration instructions must be the same name as set in the <DRIVER-TYPE> tag of the datasource XML file. Although examples are provided for the Oracle Type 4 JDBC driver, you should be able to use any of the supported JDBC drivers listed in the iPlanet Application Server Service Pack 3 Release Notes.

The Pet Store datasource files for PointBase do not require modification.
 
Driver Type Sample Datasource XML Files What to Change?
PointBase Type 4 JDBC Driver
  • EstoreDB-pointbase-type4.xml
  • InventoryDB-pointbase-type4.xml
  • SignOnDB-pointbase-type4.xml
  • nothing
Oracle Type 4 JDBC Driver 
  • EstoreDB-ora-type4.xml
  • InventoryDB-ora-type4.xml
  • SignOnDB-ias-syb-type2.xml
  • <driver-type>
  • <database-url>
  • <username>
  • <password>
Sybase JConnect Type 4 JDBC Driver 
  • EstoreDB-syb-type4.xml
  • InventoryDB-syb-type4.xml
  • SignOnDB-syb-type4.xml
  • <driver-type>
  • <database-url>
  • <username>
  • <password>
iPlanet Type 2 JDBC Driver for Oracle
  • EstoreDB-ias-ora-type2.xml
  • InventoryDB-ias-ora-type2.xml
  • SignOnDB-ias-ora-type2.xml
  • <datasource>
  • <username>
  • <password>
iPlanet Type 2 JDBC Driver for Sybase
  • EstoreDB-ias-syb-type2.xml
  • InventoryDB-ias-syb-type2.xml
  • SignOnDB-ias-syb-type2.xml
  • <datasource>
  • <username>
  • <password>

The following is an example of the EstoreDB datasource XML file as configured for an Oracle Type 4 JDBC driver. Note that the <database> and <datasource> tags are not required when registering datasources for third party JDBC drivers.

Oracle Type 4 example,

<ias-resource>
<resource>
<jndi-name>jdbc/estore/EstoreDB</jndi-name>
<jdbc>
<driver-type>ora-type4</driver-type>
<database-url>jdbc:oracle:thin:@192.18.117.186:1521:orcl</database-url>
<username>estore</username>
<password>estore</password>
</jdbc>
</resource>
</ias-resource>
And a Sybase jConnect Type 4 example,
<ias-resource>
<resource>
<jndi-name>jdbc/estore/EstoreDB</jndi-name>
<jdbc>
<driver-type>jconnect</driver-type>
<database-url>jdbc:sybase:Tds:192.138.151.39:4444</database-url>
<username>estore</username>
<password>estore</password>
</jdbc>
</resource>
</ias-resource>
Register Datasource
After modifying the datasource XML files to suit your database connection requirements, run the iasdeploy command against each file to register the datasource in the application server.

For example, to use PointBase,

1. Go to the directory
install_dir/ias/ias-samples/jps1.1.2/schema.

2. Eexecute the following commands to register the JDBC datasources:

iasdeploy regdatasource EstoreDB-pointbase-type4.xml

iasdeploy regdatasource InventoryDB-pointbase-type4.xml

iasdeploy regdatasource SignOnDB-pointbase-type4.xml

Now that you've registered the JDBC driver and datasource for Pet Store, you're ready to deploy the application.


Command Line-based Deployment

You have a choice of  deploying and registering the Pet Store application through either command line utilities or the iPlanet Application Server Deployment Tool GUI. Since a complete EAR file is supplied, the fastest means of setting up Pet Store is to use the command line utilities as described in this section. If you would like to experience deployment through a GUI tool, then follow instructions in GUI-based Deployment.

If you've decided to use a database other than PointBase, you must first modify the deployment descriptor to specify the appropriate database.

The petstore.ear file is a Enterprise ARchive file that contains the Web Archive (WAR) and EJB JAR files for the Pet Store application. Within each of these JAR files reside the XML deployment descriptor files, application class files, JSPs and other content required by the application.

Deploying the petstore.ear file is simple.

1. To use the pre-built EAR file as configured for PointBase, go to the root of the Pet Store sample directory:

install_dir/ias/ias-samples/jps1.1.2/

Alternatively, if you modified the deployment descriptor to support a database other than PointBase, you will navigate to the location at which the reassemble EAR file exists:

install_dir/ias/ias-samples/jps1.1.2/src/petstore/build/

2. Execute iasdeploy to deploy Pet Store to the local application server instance:
iasdeploy deployapp petstore.ear

The deployment process involves the following operations:

If you would like to verify the registration of the application, proceed to Verifying Registration.

Otherwise, you're ready to exercise the Pet Store application by Running the Application.


GUI-Based Deployment

The iPlanet Deployment Tool provides an easy-to-use means of assembling J2EE applications and deploying applications to the iPlanet Application Server. For most cases, use of Deployment Tool is recommended over the approach of manually creating XML-based deployment descriptors and manually assembling J2EE modules and application JAR files. In this section, we use Deployment Tool to merely read in the existing application EAR file and deploy it to the target application server. If you're interested in experiencing how to assemble a J2EE application as complex as Pet Store from scratch, following in the instructions in Assembling Java Pet Store using the Deployment Tool.

Open Pre-existing EAR File

Since a pre-built Enterprise ARchive (EAR) file for the Pet Store application is shipped with the application server, you can use the iPlanet Deployment Tool to quickly read in the EAR file, modify several deployment settings and deploy to the application server.

Open the pre-existing Pet Store EAR file.

1. Launch the Deployment Tool.

UNIX:

    Execute install_dir/ias/bin/deploytool

Windows:

    Start->Programs->iPlanet Application Server 6.0->iAS Deployment Tool

2. Open the EAR file

In the startup dialog, select "Browse for more applications" to find the petstore.ear file.

Navigate to ias/ias-samples/jps1.1.2/ and open the petstore.ear file.

Select Component View

Click on the file name to expand the EAR file.

3. If you are not using PointBase, you must modify the application's deployment descriptor to specify the appropriate database. Do this now before deploying the application.

Deploy the Application

Now you're about to deploy the application by transferring the EAR file to a target iPlanet Application Server instance. First, you will identify the target server. After the EAR file is deployed to the server, post processing is performed. After deployment has completed successfully, you will be able to run the application. No server restart is required.

1. Select the petstore.ear file under the J2EE Application window.

2. Select File -> Deploy

3. If you have not already registered a target application server, do so now by clicking on the Register button. Enter the host name, administrative port number and username/password for the target application server. Otherwise, select a pre-registered target server.

Note: You may authorize additional users to deploy applications to an iPlanet server by using the iPlanet Administrative Console. See the Security settings tab in the iPlanet Administrative Console.
4. Click on Overwrite modules in case you are repeating the deployment step.

5. Click on Deploy to start the deployment process.

6. Now the file transfer and application registration begins. See the Deploy tab for the status of the deployment. The deployment may take several minutes to complete. Once the status of the deployment changes to Success, proceed to the next section.

Verifying Registration

As an optional step, you can use the iPlanet 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.

If you don't already have the Application Server Administrative Tool running, see the Getting Started section for startup instructions.

  1. Select the server name (default name of iAS1) and select the Application button in the top right hand corner of the window to see the applications registered in this instance of the application server.
  2. You should see several folders for the "petstore" J2EE application. The "petstore" folder with the world icon represents the web application module while the "*Ejb" folders represent the EJB modules packaged as part of the Pet Store application.
To see more details associated with the Pet Store application, you can use the iPlanet Registry Editor tool.
  1. Execute kregedit from the command line to start the iPlanet Registry Editor.
  2. Navigate to the SOFTWARE/iPlanet/Application Server/6.0/ portion of the tree.
  3. Browse the J2EE-Application/ tree and look for the "petstore" application.
  4. Expand the "petstore" folder and explore this portion of the directory tree. Note the modules that make up the Pet Store application.
  5. Now open the J2EE-Module/ tree and look for the "petstore" web application module entry and the "*Ejb" EJB module entries that you noted earlier.
  6. Expand each of these folders and explore their contents.
  7. Once you find the GUID associated with each EJB in the Pet Store application, you can navigate through the SOFTWARE/iPlanet/Application Server/ClassDef/ folders to find out more details on each EJB. Expanding the matching GUID folders under the ClassDef folder will show you the detailed settings associated with each EJB. Many of these settings appear in the XML deployment descriptors for EJBs.

Running the Application

Access the Application
Start the application either by clicking here or, if you've deployed the web server on a separate machine, by accessing:

http://<hostname>/NASApp/estore/index.html

Populate the Database (first run only)
If this is the first time the application has been run, a page will be displayed to populate the database.

Select the Install Tables link and then choose the appropriate database. Assuming you are using PointBase, select the PointBase entry.

After a few moments a page will be displayed indicating that the database tables have been populated.

Run the Application

Once you've successfully populated the database, access the store's main page again:

http://<hostname>/NASApp/estore/index.html

If you experience problems when accessing the application, read through the troubleshooting section for assistance.

Note that the URL above contains "estore" rather than "petstore". Since the context root of the petstore.war module has been set to "estore" in the application.xml file, you use "estore" in place of "petstore" to refer to the web application components.

Explore the Application
Browse through the application by adding various pets to your shopping cart. When you are ready to order, either login as the predefined "j2ee" customer with password "j2ee" or create a new account.

Note that when you attempt to place an order and have not already signed in, the authentication mechanism will automatically prompt you for a user name and password before granting access to the place order screen. If you had already signed in, then the authentication page would have been bypassed and you would have proceeded directly to the place order screen.

You might find it helpful to review the Architectural Overview document to understand the design approach for the Pet Store application.

To explore the application further by deploying it to a cluster, performance testing the application, etc., see the list of additional topics to explore.

Known Issues

Search functionality does not work with Pointbase

The version of Pointbase which ships with iPlanet Application Server 6.0 sp3 does not support SQL subqueries which are needed for the search functionality. Therefore, the search functionality will not work with Pointbase.

Auto Install of Tables does not work for Oracle as the database if user is not estore

This issue is still being investigated. As a workaround, use estore as the database user.

Troubleshooting

As part of your troubleshooting efforts, ensure that you first review the General Troubleshooting section to learn how to view logs files.

Problem: Error: 500 SC_INTERNAL_SERVER_ERROR No detailed message after clicking on an image in the first page. kjs log shows general failure while attempting to obtain a database connection.

[02/Jun/2000 18:41:21:4] info: --------------------------------------

[02/Jun/2000 18:41:21:4] info: jsp.APPS.estore.productcategory: init

[02/Jun/2000 18:41:21:4] info: --------------------------------------

com.sun.estore.control.GeneralFailureException at com.sun.estore.catalog.model.CatalogImpl.getDBConnection(CatalogImpl. java:171) at com.sun.estore.catalog.model.CatalogImpl.getCategory(CatalogImpl.java :38) at jsp.APPS.estore.productcategory._jspService(productcategory.java:78) at jsp.APPS.estore.productcategory.service(productcategory.java:39) at javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source) at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unkno

Problem: Error: 500 SC_INTERNAL_SERVER_ERROR No detailed message after clicking on an image in the first page. kjs log shows BINDER errors associated with loading native database client library.
[25/Aug/2000 10:27:14:7] error: BINDER-OS: (LoadLibrary) No such file or directory
[25/Aug/2000 10:27:14:7] error: BINDER-008: GXBindWorker: error loading library libgxorcl2.so
[25/Aug/2000 10:27:14:7] error: DATA-108: failed to create a data connection with any of specified drivers
com.sun.estore.control.GeneralFailureException
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at java.lang.RuntimeException.<init>(RuntimeException.java:37)
at javax.ejb.EJBException.<init>(EJBException.java:58)

Modifying the Deployment Descriptor

Since the JPS 1.1.2 sample application that ships with iPlanet is configured to use PointBase, you need to modify the application's deployment descriptor when using a database other than PointBase.

You can modify the deployment descriptor directly using the iPlanet Application Server registry editor or you can change the deployment descriptor file, regenerate and redeploy the petstore.ear file.

Using the Application Server Registry Editor

1.Execute <application server install path>/ias/bin/kregedit to start the Registry Editor GUI.
2.Navigate to the SOFTWARE/Netscape/Application Server/6.0/ portion of the tree.
3.Expand the J2EE-Module/ tree and look for the "customerEjb" module.
4.Expand the "customerEjb" module, expand "ejbs"
5.Note the GUID number associated with the TheOrder EJB.
6.Go up to the "6.0/" folder and expand the "ClassDef/" portion of the tree.
7.Expand the folder that has the same GUID as the TheOrder EJB.
8.Expand the folder that has a version number.
9.Expand the "EntityDescriptor/" folder.
10.Expand the "env-entry/" folder.
11.Expand the folder "ejb/order/OrderDAOClass"
12.Double click on an "env-entry-value" to change its value. For example, if Oracle is the target database, then enter "com.sun.j2ee.blueprints.customer.order.dao.OrderDAOOracle"
13.After you've changed the necessary environment entries, exit the Registry Editor.

Since you have not yet run the PetStore application, there is no need to restart the application
server. The environment property values will be read in as soon as the TheOrder EJB is
loaded into memory.

Modifying Deployment Descriptor File
  1. Go to install_dir/ias/ias-samples/jps1.1.2/src/components/customer/src/ejb-jar.xml
  1. Edit the env entry "ejb/order/OrderDAOClass" to specify the implementation class for the database of your choice. For example, to use Oracle, the entry should be:

    <env-entry>
    <env-entry-name>ejb/order/OrderDAOClass</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>com.sun.j2ee.blueprints.customer.order.dao.OrderDAOOracle</env-entry-value>
    </env-entry>

    Valid class names are:

  2. Recompile and reassemble the application using the Ant-based command line utilities:
  3. cd install_dir/ias/ias-samples/jps1.1.2/src/petstore/src
    build clean
    build core

These steps will clean out the existing build directory and rebuild the entire application from scratch. The rebuilt EAR file will be placed in:

install_dir/ias/ias-samples/jps1.1.2/src/petstore/build/petstore.ear

At this stage, you are ready to deploy the EAR file.

Now proceed with deploying the application.


Recompiling and Assembling the Application

If you haven't already reviewed the sample application packaging and Ant-based build facility, please review the section Sample Application Build Facility.

Depending on the types of changes you've made to the Pet Store application, you can use different combinations of build targets to reassemble and redploy the application. In order to generate a base set of compiled classes, you should follow the Building From Scratch instructions first and then experiment with the other scenarios.

Building from Scratch
Only Deployment Descriptors Have Changed
Only Helper Classes or Web Components Have Changed

Building from Scratch

Follow these steps to rebuild the Pet Store web application and its supporting EJB components from scratch:

1. Compile and Assemble EJB JAR Components and Web Application

Execute "build" under jps1.1.2/src/petstore/src/

The default target core will be executed to rebuild the component EJBs JAR files and the petstore web application's EJB JAR and WAR files as well as the web application's EAR file.

2. Redeploy Application
Execute "build deploy" under jps1.1.2/src/petstore/src/
3. Restart Application Server
An application server restart will be necessary if you've modified either deployment descriptors or EJBs.
To clean the web application project area, execute "build clean". To also clean the component project areas, execute "build cleanall".

Only Deployment Descriptors Have Changed

If you experiment with the application by modifying only the web or EJB deployment descriptors for the application, you can simple execute "build ear" to rebuild the EJB JAR, WAR and EAR files without recompiling the Java sources and regenerating the EJB stubs and skeletons.

Then redeploy application using "build deploy" and restart the application server to pick up the descriptor changes. After the server restarts, test the application.

Only Helper Classes or Web Components Have Changed

If you change servlet, JSP or helper class source files, you can simple recreate the EAR file and update the files in the runtime environment without performing a complete reregistration of the application. In this case, since you're not modifying deployment descriptors or EJBs, you will not need to restart the application server.

Execute "build compile" if you've changed either servlet or helper classes.

Then execute "build ear" to recreate the EAR file.

Finally, execute "build update_ear" to copy the necessary files to the runtime environment without performing a formal registration of the application.

Test the application.

Note that the update_ear target is a relatively complex target in that it entails knowledge of the exact layout of the runtime application deployment directory structure. If you build a similar target for your own application, pay close attention to exactly where the files are being copied.

These steps assume that the classes and EJB JAR files for the EJBs already exist.


Clustering the Application

Since the Pet Store application has not been designed to support clustered environments in which HttpSession is replicated between application server instances, one cannot use this application to demonstrate the power and advantages of the iPlanet Application Server session replication and failover features. The specific design limitation is that the Pet Store application stores non-serializable objects on HttpSession whereas the iPlanet session replication feature requires that all HttpSession objects be serializable so that they can be transported between application server instances. iPlanet is working with the Sun Blueprints team to ensure that the next version of Java Pet Store is clusterable.

To demonstrate the true power of the application server's session replication and failover capabilities, see the Cluster sample applications. Once you've setup and exercised the simple HaServlet sample, you can cluster the Bank application and take full advantage of iPlanet's combined load balancing, session replication and failover features.

Although Pet Store as an application does not support replication of its HttpSession data, you can configure Pet Store to leverage the load balancing capabilities of the application server and to make use of multiple JVMs across multiple application server instances in a cluster. To do this, one must ensure that the application is configured with these key settings:

To ensure that Pet Store functions properly in a clustered environment, the pre-built petstore.ear file contain these "sticky" and "lite" session settings. The only other special considerations for deploying Pet Store to a cluster of application servers are the following:

Multiple Web Server Instances Require Domain Setting in Web App Descriptor

As explained in the Cluster Servlet sample, one must set the domain of the network on which the web servers are deployed in order for the browsers to send cookies back to either web server host. Since the web server plug ins are stateless, any web server configured as part of an application server cluster is capable of routing even sticky web requests back to the appropriate application server instance and on to the kjs in which the session was originally instantiated.

JDBC Data Sources Must be Registered on Each App Server Instance

Since JDBC datasource definitions are local to each application server instance, you must register your JDBC datasource with each instance.

Application Must be Registered on Each App Server Instance

Although a common directory server is used to stored the application server registry settings, there are application web content, JAR and class files that must be expanded to the file system of each application server instance. Consequently, one must register the application with each application server instance in the cluster.

Next Steps

If you are interested in deploying Pet Store to multiple application server instances in a cluster, then it is recommended that you first configure a simple cluster and deploy and exercise the HaServlet sample. After you've successfully run through various failure scenarios with the servlet sample, then you can proceed with the following steps to setup Pet Store for the same cluster environment.

1. Validate and exercise the two machine cluster as described in the cluster servlet sample.

2. Register the JDBC datasources on each application server instance. See the Register Datasources section for details.

3. If you intend to distribute web requests from the browser across the two different web server instances, you must set the domain field of the web application. See the Cluster Servlet sample setup instructions for details on how to modify this setting.

4. Register the application on each server in the cluster. Since the application server instances share a directory server for the registration of the applications, it is very important that you register the application across the server instances in a sequential manner. See the Cluster Servlet sample deployment section for details.

When exercising the application in a cluster, use multiple browsers on multiple machines to observe how new sessions are load balanced across different JVMs and how each session "sticks" to the JVM on which it was instantiated.


Performance Testing the Application

Several considerations should be kept in mind prior to running performance tests against the Java Pet Store application.

Migrate Static Web Content to Web Server Tier

To relieve the application server from the burden of serving static web content, it is recommended that all static content be deployed to the web server tier. For the Java Pet Store application, you will need to perform the following steps:

Consider Using JSP Caching for Shared Pages

Although Pet Store contains many session-specific pages, there are a number of JSPs whose output is shared across user sessions. You might observe a minor performance enhancement by configuring caching for these JSPs. Refer to the iPlanet Application Server's Java Programmer's Guide on http://docs.iplanet.com for more information on JSP caching.

Disable Session Replication if Desired

If your performance test does not require replication of HttpSession data, then ensure that distributed session support is disabled. The ias-web.xml file contains a <session-info> area in which session replication settings are defined. Specifically, the <impl> and <dsync-type> are two tags of interest.

Refer to the chapter entitled "Packaging for Deployment" in the iPlanet Application Server's Java Programmer's Guide on http://docs.iplanet.com for more information on session replication configuration.

Ensure Application Server Environment is Tuned

Ensure that the following aspects of the application server environment are properly tuned: You should also experiment with running several Java Engines if your system has more than several CPUs. As a starting point, it is recommended that you configure one JVM per CPU.

Deploying the Administrative Application

A simple administrative web application is bundled with Java Pet Store 1.1.2. Before deploying this application, ensure that the Java Pet Store application is working properly.

Populating the Directory describes how to add an initial set of Pet Store administrators to the LDAP-based Directory Server.

Deploying and Running the Application describes how to deploy and access the PetStore Admin appplication

Populating the Directory

The iPlanet Application Server leverages an LDAP-based directory server for user authentication in the petstoreadmin application. To support the standard J2EE form-based authentication feature used by the Java Pet Store Admin application, you must add a user and group to the directory server prior to running the application. You can use either the ldapmodify command line interface or the GUI-based Directory Server Administrative Tool to process the EstoreUser.ldif file containing the Java Pet Store user and group entries. Before adding the entries, you will need to modify the domain name contained in the LDIF file to suit your environment.

Prepare the LDIF File

A sample LDIF file containing the necessary user is packaged as part of the Pet Store application source code. You'll need to edit this file and change the o=iplanet.com references to o=<your domain name> (for example, o=mycompany.com). Then you can use the ldapmodify utility to add the users and groups to your directory server. Follow these steps to update the LDIF file:
  1. Edit the file install_dir/ias/ias-samples/jps1.1.2/schema/EstoreUser.ldif
  2. Change all "iplanet.com" references to the same domain name as used in your directory server installation. For example, change all "iplanet.com" entries to "mycompany.com". Depending on your domain setting you may have to specify two or three level domain names. For example, "group.mycompany.com" might be necessary in place of "mycompany.com".
After having modified the LDIF file, you will need to use either the GUI-based Directory Server Administration Tool or the ldapmodify CLI to import the LDIF file into the directory server.

GUI-Based Directory Server Administrative Tool

In this approach, you will use the Directory Server's GUI-based administrative tool to import an LDIF file containing the definition of users and groups to support the Java Pet Store application.

If you don't already have the Directory Server Administrative Tool running, see the Getting Started section for startup instructions.

In the Directory Server Administrative Tool, click on Configuration tab and select the Database node. Then select the menu item Object->Import.

Click on Browse to navigate to the following location:

install_dir/ias/ias-samples/jps1.1.2/schema
Select the EstoreUser.ldif file and click on OK to add the entries to the directory server. If you encounter a message stating "0 entries imported, n entries rejected", then you probably have not modified the content of the LDIF file to suit your network environment.

To review the new additions, click on the Directory tab and expand the folder containing your domain name. Under Groups, you should see EstoreAdmin. Under People, your should see three estore users.

Now that you've defined and populated the database tables, defined the necessary JDBC driver and datasources and added the Java Pet Store entries to the directory server, proceed to either the Command Line Deployment section or the GUI-Based Deployment section to deploy the application.
 

ldapmodify Command Line Interface

Follow one of the next two sections to run the ldapmodify command line utility to populate the directory with users and groups needed by the Pet Store application.

UNIX: ldapmodify

1. First ensure that the directory server is running.
    ps -ef | grep slapd

    nobody 27315 1 0 Dec 04 ? 4:53 ./ns-slapd -f /usr/iPlanet/ias6/slapd-miwok/config/slapd.conf

2. Modify your LD_LIBRARY_PATH before running the ldapmodify command:
export LD_LIBRARY_PATH=install_dir/ias/gxlib:$LD_LIBRARY_PATH

For example,

export LD_LIBRARY_PATH=/usr/iplanet/ias6/ias/gxlib:$LD_LIBRARY_PATH
This setting will enable ldapmodify to find the necessary libraries.
3. Go to the install_dir/ias-samples/jps1.1.2/schema/ directory and run the ldapmodify command to populate the directory:
install_dir/shared/bin/ldapmodify -D"cn=Directory Manager" -w <password> -a -f EstoreUser.ldif

For example,

/usr/iplanet/ias6/shared/bin/ldapmodify -D"cn=Directory Manager" -w password -a -f EstoreUser.ldif

adding new entry uid=jps_admin, ou=People, o=iplanet.com

adding new entry cn=EstoreAdmin, ou=Groups, o=iplanet.com

Where:
-D"cn=Directory Manager" specifies the distinguished name with which to authenticate to the server. This is the name that was supplied during iPlanet installation.

-w <password> specifies the password for the directory server Directory Manager.

If you're running the directory server on a port other than 389, then add the -p option to supply a port number. For example, -p 1049.

If the directory server is on another host that the local host, then add the -h option to specify the target host name of the directory server. For example, -h cyclops.

If the following error occurs, it most likely means that you specified an incorrect domain name in the EstoreUser.ldif file.

root@canteloupe: /usr/iplanet/ias6/shared/bin/ldapmodify -D"cn=Directory Mana...

adding new entry uid=j2ee, ou=People, o=red.iplanet.com

ldap_add: No such object

Edit the .ldif file and change the "o=" attribute to the proper value. In this example, iplanet.com should be used in place of red.iplanet.com.
Now that you've defined and populated the database tables, defined the necessary JDBC driver and datasources and added the Java Pet Store entries to the directory server, proceed to either the Command Line Deployment section or the GUI-Based Deployment section to deploy the application.

Windows: ldapmodify

1. First ensure that the directory server is running.
Start->Settings-Control Panel and start Services.

Verify that Netscape Directory Server is running.

2. Go to the install_dir/ias-samples/jps1.1.2/schema/ directory and run the ldapmodify command to populate the directory:
ldapmodify -D"cn=Directory Manager" -w <password> -a -f EstoreUser.ldif

Where:

-D"cn=Directory Manager" specifies the distinguished name with which to authenticate to the server. This is the name that was supplied during iPlanet installation.

-w <password> specifies the password for the directory server Directory Manager.

If you're running the directory server on a port other than 389, then add the -p option to supply a port number. For example, -p 1049.

If the directory server is on another host that the local host, then add the -h option to specify the target host name of the directory server. For example, -h cyclops.

If the following error occurs, it most likely means that you specified an incorrect domain name in the EstoreUser.ldif file.

ldapmodify -D"cn=Directory Mana...

adding new entry uid=j2ee, ou=People, o=red.iplanet.com

ldap_add: No such object

Edit the ldif file and change the "o=" attribute to the proper value. In this example, iplanet.com should be used in place of red.iplanet.com.
Now that you've defined and populated the database tables, defined the necessary JDBC driver and datasources and added the Java Pet Store entries to the directory server, proceed to either the Command Line Deployment section or the GUI-Based Deployment section to deploy the application.

Deploying and Running the Application

Deploying the pre-built petstoreadmin.ear file is simple.

1. Go to the root of the Pet Store sample directory:

install_dir/ias/ias-samples/jps1.1.2/
2. Execute iasdeploy to deploy Pet Store Admin Application to the local application server instance:
iasdeploy deployapp petstoreadmin.ear
3. Access the Application

Start the application either by clicking here or, if you've deployed the web server on a separate machine, by accessing:

http://<hostname>/NASApp/estoreadmin/index.html

As the main page is displayed, click on the link and login as the user "jps_admin" with password "admin". On the Manage Orders screen, you can modify the status of all pending orders.

As an experiment, you can bring up two browsers: one to interact with the mainstream Java Pet Store web application and another to run the administrative application. As orders are placed, you will see updates in the administrative application.


Deploying the Mailer Mini Application

A simple mailer mini application is bundled with Java Pet Store 1.1.2. Before deploying this application, ensure that the Java Pet Store application is working properly.

Deploying the pre-built mailerapp.ear file is simple.

1. Go to the install_dir/ias/ias-samples/jps1.1.2/schema/ directory and edit the mail-resource.xml file. Change the host, mail server user name and reply to address fields to suit your environment.

<ias-resource>



   <resource>



   <jndi-name>mail/estore/MailSession</jndi-name>



   <mail>



   <host>mailserver.iplanet.com</host>



   <name>juser</name>



   <address>juser@iplanet.com</address>



   </mail>



   </resource>



</ias-resource>
2. Using the iasdeploy CLI, register the mail resource:
iasdeploy regdatasource mail-resource.xml
3. Go to the root of the Pet Store sample directory:
install_dir/ias/ias-samples/jps1.1.2/
4. Execute iasdeploy to deploy Pet Store Admin Application to the local application server instance:
iasdeploy deployapp mailerapp.ear
5. Access the Application

Start the application either by clicking here or, if you've deployed the web server on a separate machine, by accessing:

http://<hostname>/NASApp/mailerapp/index.jsp

As the main page is displayed, click on the link "Try the Blueprints Mailer". On the Blueprints Mailer screen, you can fill in the fields to send a mail.


Enabling Order Confirmation via E-mail

The Java Pet Store demo can be configured to send a confirmation e-mail to a customer when an order is completed. This feature is turned off by default. E-mail order notification uses the mail services of the J2EE platform, and can be enabled at deployment time. This section describes the steps necessary to turn on e-mail order notification.

1. Under the Java Pet Store web application source directory, modify the ejb-jar.xml file so that the env-entry-value of sendConfirmationMail is true:


     <env-entry-name>sendConfirmationMail</env-entry-name>



     <env-entry-type>java.lang.Boolean</env-entry-type>



    <env-entry-value>true</env-entry-value>
2. Since the MailerEJB's ias-ejb-jar.xml already contains a mapping to the appropriate JNDI name for the mail resource, there is no need for you to modify the configuration of the MailerEJB.

     <resource-ref>

        <res-ref-name>mail/MailSession</res-ref-name>

        <jndi-name>mail/estore/MailSession</jndi-name>

    </resource-ref>
3. This step needs to be done only if a mail resource has not been deployed yet. Go to the install_dir/ias/ias-samples/jps1.1.2/schema/ directory and edit the mail-resource.xml file. Change the host, mail server user name and reply to address fields to suit your environment.
<ias-resource>



   <resource>



   <jndi-name>mail/estore/MailSession</jndi-name>



   <mail>



   <host>mailserver.iplanet.com</host>



   <name>juser</name>



   <address>juser@iplanet.com</address>



   </mail>



   </resource>



</ias-resource>
4. Using the iasdeploy CLI, register the mail resource:
iasdeploy regdatasource mail-resource.xml
5. Rebuild the jps1.1.2 source code and deploy the mail-enabled Pet Store application.
(As an alternative to editing the ejb-jar.xml file, reassembling and redeploying the application, you can start kregedit and modify the sendConfirmationMail environment property directly. You will need to find the GUID of the ShoppingClientControllerEJB under the ClassDef section of the Registry and edit the underlying environment setting.)

6. After modifying the sendConfirmationMail environment entry (either in the XML file or directly in the Registry), restart the application server to pick up the environment setting change.

7. To exercise the configuration, enter the Pet Store application and sign in as the "j2ee" user. Select "MyAccount" and change the e-mail address to a valid address. Perform a shopping order cycle to trigger generation of a mail message confirming your purchase.

The confirmation e-mail message that is sent to the specified address should resemble the following:

Subject: Your order#4
Date: Tue, 9 Jan 2001 20:53:30 -0800 (PST)
From: root@canteloupe.red.iplanet.com
To: ckamps@iplanet.com

This mail is a confirmation for your order# 4
Please save it for your records.
Your order will be shipped to:
ABC XYX
The total cost of your order is $23.5

Copyright (c) 2001 Sun Microsystems, Inc. All rights reserved.