Bank Application
iPlanetTM Application Server J2EE Samples

Updated  June 12, 2001

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

The Bank sample application provides a web-based interface to a basic online banking service. A collection of servlets interact with two stateless session beans to provide customers with balance inquiry and account transfer services. Bank customer service representatives are able to add new customers and remove existing customers from the bank's database as well as from the directory server. Additional features of note include:

The Bank sample application was known as "nsOnlineBank" in Netscape Application Server (NAS) 4.0. This application was ported to JavaTM 2 Enterprise Edition (J2EE) for iPlanet Application Server 6.0.

Although Bank uses several key features of the J2EE programming model, you should also consider exercising Sun Microsystem's popular Java Pet Store application on iPlanet Application Server.

Setting Up the Environment

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

Configuring the Database describes how to setup the database schema, load the content and register the JDBC data sources for the Bank application.

Populating the Directory describes how to add Bank users and groups to the directory server.

Deploying and Running the Bank Application

Select one of two approaches to deploying and registering the application:

Command Line-based Deployment describes how to manually register the bank application in iPlanet using a Command Line Interface (CLI). This is the fastest means of deploying the Bank to the application server.

GUI-based Deployment describes how to use the iPlanet Deployment Tool to import and deploy the Bank application. Alternatively, you can also assemble the application from scratch and deploy it using the Deployment Tool.

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

Further Exploration

Using Third Party JDBC Drivers describes how to configure the application to use a non-iPlanet JDBC driver to access the database.

Compiling and Assembling the Application describes how to use command line tools to recompile the sources and rebuild the WAR and EJB modules and the overall EAR file.

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


Configuring the Database

The bank sample application requires the following database setup prior to running the application:
Ensure Database Requirements are Met

Ensure Database Driver is Registered

Identify or Create a Database User

Create and Populate Sample Database Tables

Ensure Database Requirements are Met

See the iPlanet Application Server Release Notes for database version requirements. Database population and setup scripts are provided for the following databases:

Note: The bundled Pointbase database is not supported for this sample

Ensure Database Driver is Registered

This section describes how to register an underlying database driver with the application server 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. The subsequent section of this document will describe how to populate the database tables and register JDBC data sources.

Determine if the iPlanet Type 2 Driver is Registered

On UNIX, if during installation the application server, either "Typical" or "Express" installation options were selected, the native database driver will not be registered in the application server. If you are unsure as whether or not the client driver was registered, use the application server's Administrative Tool to determine status of JDBC drivers.
  1. Start the Admin Tool
  2. install_dir/ias/bin/ksvradmin
  3. Connect to your application server instance by selecting File->New->Server. Click on Localhost to specify the default connection settings. Enter the application server's 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 in the application server. Go to the next section to register the driver.
On Windows, the application server automatically detects whether or not drivers for any of the supported databases are available. If a driver is present, the driver will be automatically registered during installation of the application server.

Register 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 the application server.

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 native client driver. The default application server installation root directory is /usr/iplanet/ias6.
  5. For the Bank sample, you need not register a Resource Manager. (Resource Manager setup is required only in support of distributed and possibly heterogeneous transactions relying on the application server's built-in transaction manager).
  6. Restart the application server using the iascontrol stop and iascontrol start commands.
  7. After you've registered the driver, you can use the application server's Admin Tool (ksvradmin) to verify that the native driver entry no longer shows a red X and that the client library and other settings are accurate.

Identify or Create 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 bank using the Oracle SQL Plus utility. It is strongly recommended that a user such as bank be used to create the Bank database tables. This approach will help to avoid confusion between table names used in other applications.

To define a new Oracle user:

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

  2. SQL > create user bank identified by bank;

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

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

Create and Populate the Sample RDBMS Tables

A shell script named setup_<rdbms type>.sh/.bat configures the database tables, populates the tables with sample data and updates the application server's registry with database information to support the Bank sample application. The setup_<rdbms type>.sh/.bat script performs the following steps:
  1. Dynamically creates an XML file describing the JDBC datasource.
  2. Invokes the application server's iasdeploy regdatasource command to register the data source resource in the application server's registry.
  3. Verifies connectivity to the specified database.
  4. Creates the tables required by the Bank application and populates the tables.
Go to the install_dir/ias/ias-samples/bank/src/schema/ directory and find the setup_<rdbms type>.sh/.bat file that corresponds to the database of interest. Now follow these instructions:
UNIX: Create and Populate RDBMS

Windows: Create and Populate RDBMS

UNIX: Create and Populate RDBMS

  1. Ensure that the RDBMS enviornment variable is set appropriately. For example, ORACLE_HOME or SYBASE.

  2.  
  3. Edit setup_<rdbms type>.sh. Set the GX_ROOTDIR environment variable to the location of the ias/ directory in your application server installation.
For example,
GX_ROOTDIR=/usr/iplanet/ias6/ias
3. Run setup_<dbname>.sh with the following arguments:
setup_ora.sh <TNS name> <dbusername> <dbpassword>

setup_syb.sh <Server Name> <database> <dbusername> <dbpassword>

For example using Oracle:
setup_ora.sh iassample bank bank

Where:

<TNS Name> is the Oracle service or TNS name which maps to the appropriate Oracle database instance. In the example above, "iassample" is the Oracle service or TNS name. (This assumes that the Oracle client has been configured to recognize "iassample" as a valid Oracles service/TNS name.)

<dbusername> and <dbpassword> are the Oracle user name and password under which the tables will be created and populated. These are also the values that will be used by the sample application to access the Oracle database.

Since the setup_ora.sh script uses sqlplus, ensure that LD_LIBRARY_PATH includes $ORACLE_HOME/lib.

For example using Sybase:
setup_syb.sh SYBIAS iassample iasdemo iasdemo

Where:

<Server Name> is the Sybase server name and port number. In the example above, ?SYBIAS? is the Sybase server name.

<database> is the Sybase database name.

<dbusername> and <dbpassword> are the Sybase user name and password under which the tables will be created and populated. These are also the values that will be used by the sample application to access the Sybase database.

Windows: Create and Populate RDBMS

1. Ensure that the RDBMS enviornment variable is set appropriately. For example, ORACLE_HOME or SYBASE.

2. Run setup_<rdbms type>.bat with the following arguments:

setup_ora <TNS name> <dbusername> <dbpassword>

setup_syb <Server Name> <database> <dbusername> <dbpassword>

setup_mssql <Server Name> <database> <dbusername> <dbpassword>

For example using Oracle:
setup_ora iassample bank bank
Where:

<TNS Name> is the Oracle service or TNS name which maps to the appropriate Oracle database instance. In the example above, "iassample" is the Oracle service or TNS name. (This assumes that the Oracle client has been configured to recognize "iassample" as a valid Oracles service/TNS name.)

<dbusername> and <dbpassword> are the Oracle user name and password under which the tables will be created and populated. These are also the values that will be used by the sample application to access the Oracle database.

For example using Sybase:

setup_syb SYBIAS iassample rrs rrs

Populating the Directory

Since the Bank application uses the directory server to authenticate users and authorize access to the banking services, a set of sample users and groups must be added to the directory server.

Prepare the LDIF File

A sample LDIF file containing the necessary users and groups is packaged as part of the Bank 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=sun.com). Then you can use the ldapmodify command 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/bank/src/schema/BankUser.ldif
  2. Change all references to "iplanet.com" to the same domain name as defined in the directory server installation. For example, change all "iplanet.com" entries to "yourcompany.com".
  3. Now follow one of the following two sections to run the ldapmodify utility to populate the directory with users and groups needed by the Bank 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/iAS 6/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/bank/src/schema directory and run the ldapmodify command to populate the directory:
install_dir/shared/bin/ldapmodify -D"cn=Directory Manager" -w <password> -a -f BankUser.ldif

For example,

/usr/iplanet/ias6/shared/bin/ldapmodify -D"cn=Directory Manager" -w password -a -f  BankUser.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 installation of the application server.

-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.

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/bank/src/schema directory and run the ldapmodify command to populate the directory:
ldapmodify -D"cn=Directory Manager" -w <password> -a -f BankUser.ldif

For example,

/usr/iplanet/ias6/shared/bin/ldapmodify -D"cn=Directory Manager" -w password -a -f BankUser.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 installation of the application server.

-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 BankUser.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.

Verify Directory Server Additions

Use the Netscape Administrative console to verify that the directory server changes occurred:
    UNIX:
    install_dir/startconsole
    Windows:
    Start->Programs->Netscape Server Family->Netscape Console 4.0
Go to <system name>->Server Group and double click on Directory Server.

In the Directory Server admin tool, click on Directory tab and expand your domain name's folder to see the Groups and People defined for your domain.

Click on Groups. You should see several groups under the group name BankApp of interest to the Bank application: BankAdmin and BankUser. These two subordinate groups are used by the BankService EJB. Under each group, you can click on the Members tab to see who belongs to each group.


Command Line-based Deployment

You have a choice of  deploying and registering the Bank 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 Bank is to use the command line utilities as described in this section. If you would like to experience either deploying through a GUI tool or assembling an application from scratch, then follow instructions in GUI-based Deployment.

The pre-built bank.ear file is a Enterprise ARchive file that contains the Web Archive (WAR) and EJB JAR files for the Bank 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 pre-built bank.ear file is simple.

1. Go to the root of the Bank sample directory:

install_dir/ias/ias-samples/bank/

2. Execute iasdeploy to deploy Bank to the local application server instance:

install_dir/ias/bin/iasdeploy deployapp bank.ear

The deployment process will take 30 seconds to a minute or so to complete.

The deployment process involves the following operations:

Your next step is to customize several environment settings to suit your network environment.

Modifying BankService EJB Environment Settings

The BankService EJB interacts with the directory server to manage the creation and deletion of customers. To enable the BankService bean to connect and effect changes to the directory server, the directory server connection settings (host name, port number, etc.) and authentication properties must be provided to the EJB. In the Bank application, these properties are defined in the environment settings within the EJB's deployment descriptor.

To run Bank in your specific network domain, you will need to modify one or more these environment settings.

There are two means by which you can modify the EJB environment settings:

  1. iPlanet Application Server Deployment Tool
  2. iPlanet Application Server Registry Editor
Since we're manually deploying the Bank application, we'll use the application server's Registry Editor (kregedit) to modify the default EJB environment settings. Before we use the Registry Editor, let's take a look at the settings and their role in the application.

BankService EJB Environment Settings

This table lists the environment settings required by the BankService EJB. The values depicted in bold are values that you might need to modify for your particular application server installation and network domain name. You should consult this table when you are using either the Deployment Tool or performing a manual registration.
 
Environment Name Default Value Description
GROUP_DN cn=BankUser, cn=BankApp, ou=Groups, o=iplanet.com   
AUTH_DOMAIN uid=admin, ou=Administrators, ou=TopologyManagement, o= NetscapeRoot  User under which BankService modifies directory server.
AUTH_PASSWORD admin Password for admin user.
HOST localhost Directory server host name.
PORT 389 Directory server port number.
USER_ROOT ou=People,o=iplanet.com Root where Bank users are located.

Using the Application Server Registry Editor

Since you manually registered the Bank application using the iasdeploy command, then you need to use the kregedit tool to modify the BankService EJB's environment settings.
  1. Execute install_dir/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 "bankEjb" module.
  4. Expand the "bankEjb" module, expand "ejbs"
  5. Note the GUID number associated with the BankService 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 BankService EJB.
  8. Expand the folder that has a version number.
  9. Expand the "SessionDescriptor/" folder.
  10. Expand the "env-entry/" folder.
  11. Expand the folders associated with the environment entries that must change for your network environment and application server installation. See the table above for the meaning of each environment property.
  12. Double click on an "env-entry-value" to change its value.
  13. After you've changed the necessary environment entries, exit the Registry Editor.
Since you have not yet run the Bank application, there is no need to restart the application server. The environment property values will be read in as soon as the BankService EJB is loaded into memory.

Now you're ready to exercise the Bank application. Proceed to Running the Application.


GUI-based Deployment

The Deployment Tool provides an easy to use means of assembling J2EE applications and deploying them to the application server. Compared to the effort and risks involved in the manual creation of J2EE deployment descriptors and modules, the Deployment Tool provides an easy-to-use means of deploying your application to the application server.

Two approaches to using the Deployment Tool are described:

Import Pre-existing EAR File to quickly deploy the Bank application. None of the application assembly steps are covered by this section. On average, this approach will take 15 minutes.

or

Assemble Bank Application to learn how to use Deployment Tool to assemble and deploy the Bank application. On average, this approach will take from 30 to 60 minutes.

Import Pre-existing EAR File

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

Import the EAR File

Open the pre-existing Bank EAR file.

1. Launch the Deployment Tool.

2. Open the bank.ear file

Modify Environment Settings

Modify environment settings of the BankService EJB so that it can communicate with the directory server as deployed in your environment. These changes will result in modifications being made the XML deployment descriptor associated with the bankEjb.jar file in the bank.ear file.
  1. Expand the bankEjb.jar module.
  2. Select BankService EJB, right click and select Edit Descriptor.
  3. Select the Environment tab.
  4. Modify the environment entries to suit your installation environment. The default domain of "iplanet.com" will need to be changed to match your domain name.  The default HOST and PORT values might also need to be modified for your installation. See the BankService EJB Environment Settings section for information on these properties.
  5. Save the environment changes by closing the closing the descriptor window.
  6. Select the bank EAR module and select File->Save to save the descriptor changes to the EJB JAR and EAR files.
Proceed to Deploying the Application

Assemble Bank Application

Compile Application Sources

To compile the application sources, simply execute "build compile" under the application's src/ directory. See the section Compiling and Assembling the Application for more information on recompiling the application using the supplied build facility.

Create bankEjb.jar Module

Insert EJBs and Supporting Classes

1. Create assembly location:
Create the new directory install_dir\ias\ias-samples\bank\assemble\ outside the Deployment Tool. You will assemble the application into JAR files and save them to this directory.
2. Launch the Deployment Tool:
UNIX: Execute install_dir/ias/bin/deploytool&

Windows: Programs->iPlanet Application Server 6.0->iAS Deployment Tool

3. Create bankEjb.jar: 4. Now insert all class files needed in the bankEjb.jar file:

Modify EJB Names

We will now rename the EJBs to names different than their default names. To perform the rename, we must open up the descriptor for each EJB and rename the bean. After saving each descriptor, we will save the EJB JAR file to force the rename to take effect. Then we will reopen the EJB JAR file and continue with assembling the EJB JAR module.
Original Name New Name
IBankService BankService
ICustomerService CustomerService

Modify Deployment Descriptor Settings for BankService

1. Modify Descriptor for BankService EJB 2. Begin Modifying the BankService EJB Descriptor 3. Add Environment Settings

This EJB requires several environment settings to be declared in advance. Select the Environment Tab to add the following variables. You might have to modify the bold values according to your environment and installation options.
 
Key Name Type Value 
GROUP_DN String cn=BankUser, cn=BankApp, ou=Groups, o=iplanet.com
AUTH_PASSWORD String admin 
AUTH_DOMAIN String uid=admin, ou=Administrators, ou=TopologyManagement, o=NetscapeRoot 
HOST String localhost
PORT Integer 389
USER_ROOT String ou=People, o=iplanet.com

4. Resource References

In the References Tab, enter the following data under the References to Resources:

 
Resource Name Resource Class Authorization JNDI Name
BankDataSource javax.sql.DataSource Container jdbc/bank/BankDB

5. Close the Descriptor for the EJB

Now we can close the EJB descriptor by clicking on the X in the upper right hand corner of the descriptor window. Click on Yes when asked to save the changes.

Modify Deployment Descriptor Settings for CustomerService

1. Modify Descriptor for CustomerService EJB 2. Begin Modifying the CustomerService EJB Descriptor 3. Resource settings for CustomerService

In the References Tab, enter the following data under the References to Resources:

 
Resource Name Resource Class Authorization JNDI Name
BankDataSource javax.sql.DataSource Container jdbc/bank/BankDB
4. Close the Descriptor for the EJB

Now we can close the EJB descriptor by clicking on the X in the upper right hand corner of the descriptor window. Click on Yes when asked to save the changes.

Save and close bankEjb.jar

Now that we've assembled the EJB JAR module, we're ready to move on to assembling the Web Application aRchive (WAR) file.

Create bank.war Module

Identify the Content for WAR File

1. Create bank.war: 2. Now insert all class files needed in the bank.war file: 3. Add all JSP and HTML files needed to the .war file 4. Add all image files needed to the .war file

Modify Names of All Servlets

Our next step is to rename all of the servlets. To perform the rename, we must open up the descriptor for each servlet and rename the servlet. After saving each descriptor, we will save the WAR file to force the rename to take effect. Then we will reopen the WAR file and continue with assembling the WAR module.
 
Initial Name New Name
For all servlets except for the following 3 names: 

xyzServlet

xyz

e.g. "BankServlet" becomes "Bank"

TransferDetailsServlet ShowTransferDetails
ViewTransactionServlet ViewTransactions
BankLoginServlet Login

Modify Web Application Descriptor

Now we need to make several changes to settings at the WAR module level. To do so, select either the WAR file path if in File View or the WAR module name if in Component View. Right click and select Edit Descriptor.

As described for the bankEjb.jar, in the following paragraphs, the title gives the tab name, where you have to enter the data given below.

1. General Tab

 
Name: bank
Distributable checked
Session Timeout (seconds): 400
Authentication Type form
Login Form /bank/index.jsp
Login Error Page /bank/LoginError.jsp
2. iAS Tab
 
Distributed Session checked
Timeout (seconds): 400
Timeout Type Since last access
Data Synchronization Distributed
3. References Tab
EJB References:
 
Reference Bean Type Linked to Bean Bean Home Interface Bean Remote Interface
BankServiceBean Session BankService com.iplanet.ias.bank.bank.IBankServiceHome com.iplanet.ias.bank.bank.IBankService
CustomerServiceBean Session CustomerService com.iplanet.ias.bank.customer.ICustomerServiceHome com.iplanet.ias.bank.customer.ICustomerService
4. Roles Tab
Security Roles
Role Name Description
BankUser the bank user role
BankAdmin the bank administrator role

5. Security Tab

Define Resource Collections
Resources URL Pattern Method
MySecureBit0 /Login POST
Access Control for Resource Collections
Collection Roles Transport Guarantee
MySecureBit0 BankUser NONE
MySecureBit0 BankAdmin NONE

Save and close bank.war

Now that we've assembled both J2EE modules (EJB JAR and WAR), we're ready to move on to assembling the modules into an EAR file.

Assemble bank.ear

1. Create bank.ear: 2. Add bankEjb.jar and bank.war Files: 3. Enter Security Role definitions
 
Role Name Description
BankUser customers
BankAdmin administrators
4. Set Context Root for Web Application

Next, we need to set the context root of the web application. This value will appear in URLs that access web application components. For example, in the URL http://localhost/NASApp/bank/Login the "bank" value is the context root of the web application.

5. Save bank.ear: Now that the EAR file has been assembled, the next step is to deploy the application to an application server instance.

Deploy the Application

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

If you followed the assembly instructions, then bank.ear is opened in Deployment Tool. If you opened the pre-existing EAR file, you are working with install_dir\ias\ias-samples\bank\bank.ear. If you are following the "Create EAR File from Scratch" instructions, you are modifying install_dir\ias\ias-sample\bank\assemble\bank.ear.

If you entered all deployment information manually, you can skip the following steps 1 to 3, because you have entered this information already.

1. Select the bank.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 application server server by using the application server's Administrative Console. See the Security settings tab in the 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. Role Mapping for Bank: If you read in the pre-built EAR file, the mapping between logical J2EE roles and the groups and users found in the directory server has already been made. In this case, simply click on OK to accept the pre-assigned mappings. If you are assembling the application from scratch, you will need to resolve the J2EE roles to groups and/or users found in the directory server.

6a) Click on "BankAdmin" and click on Edit to map this role to the BankAdmin group.

6b) Do the same for the "BankUser" role (which maps to the group named BankUser) and click OK to accept the role assignments.

7. 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

After you've deployed the application, you're ready to use several application server administrative tools to verify that the application is available.
  1. Start the Application Server Admin Tool
  2. UNIX:
    install_dir/ias/bin/ksvradmin
    Windows:
    Start->Programs->iPlanet Application Server->iAS Administration Tool
  3. Connect to your application server instance by selecting File->New->Server. Click on Localhost to specify the default connection settings. Enter the application server administrator's password and click on OK.
  4. 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.
  5. You should see several folders for the "bank" J2EE application. The "bank" folder with the world icon represents the web application module while the "bankEjb" folder represents the EJB module packaged as part of the Bank application.
To see more details associated with the Bank application, you can use the lower level tool named kregedit:
  1. Execute kregedit to start the application server's Registry Editor GUI.
  2. Navigate to the SOFTWARE/iPlanet/Application Server/6.0/ portion of the tree.
  3. Browse the J2EE-Application/ tree and look for the "bank" application.
  4. Expand the "bank" folder and explore this portion of the directory tree.
  5. Now open the J2EE-Module/ tree and look for the "bank" web application module entry and the "bankEjb" EJB module entry.
  6. Expand each of these folders and explore their contents.
  7. Once you find the GUID associated with each EJB in the Bank 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

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

http://<web server hostname>:<port>/NASApp/bank/Login

1. After the login page appears, login as one of the bank customers listed on the login page.

2. Explore the available services. Transfer money from one account to another, view balances, etc.

3. Logout and log back in as a Customer Service Representative (bankrep/bankrep).

4. Explore the different set of services available to a Customer Service person.

Note that although the application supports adding new customers, there is no easy means of logging in as the newly added customer. Since there is no password data entry field in the new customer form, you will not know the password assigned to this user. You should be able to go into the directory server, modify the user's password and then try to login to the Bank 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.

Troubleshooting

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

Problem: When accessing the Bank application login page, a login dialog window pops up in the browser.

Problem: When Accessing Customer Balances, Unexpected System Error is Displayed Problem: Error when adding a new customer. You might see LDAP errors in the .../ias/logs/kjs* log file.

Using Third Party JDBC Drivers

As of iPlanet Application Server 6.0 Service Pack 1, third party JDBC drivers can be configured to leverage the connection pooling facilities built into the application server. To use a third party JDBC driver in conjunction with the Bank application, you must perform two steps:
  1. Register the JDBC Driver with the Application Server
  2. Reregister the JDBC Data Source for the Bank Application
  3. Restart the Application Server
1. Register the JDBC Driver with the Application Server

See the iPlanet Application Server SP3 Release Notes for a complete description of registering third party JDBC drivers in the application server. The basic steps are as follows:

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. Native drivers
2. Third party jdbc drivers
To accept the default shown in brackets, press the Enter key.

Select the component you want to install (1/2) [1]:
(SELECT OPTION 2 FOR JDBC )

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

d) Enter the driver class name.

e) Enter the fully qualified path of the driver JAR or ZIP file.

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

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

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

b) Enter the driver class name.

c) Enter the fully qualified path of the driver JAR or ZIP file.

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

2. Reregister the JDBC Data Source for the Bank Application

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 an example is 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 1 Release Notes. See the following sample:

ias-samples/bank/src/schema/BankDB-ora-type4.xml
The following is an example of the BankDB 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. Compare and contrast the Type 4 datasource examples with the iPlanet Type 2 datasource XML samples.
<ias-resource>
<resource>
<jndi-name>jdbc/bank/BankDB</jndi-name>
<jdbc>
<driver-type>ora-type4</driver-type>
<database-url>jdbc:oracle:thin:@192.18.117.186:1521:orcl</database-url>
<username>bank</username>
<password>bank</password>
</jdbc>
</resource>
</ias-resource>

After modifying the datasource XML files to suit your database connection requirements, run the iasdeploy regdatasource command against each file to register the datasource in the application server. For example,

iasdeploy regdatasource BankDB-ora-type4.xml

3. Restart the Application Server

After restarting the application server to pick up the third party database driver and datasource changes, restart your browser and rerun the sample application.


Compiling and Assembling the Application

To easily recompile, assemble and deploy the application, see the Sample Application Build Facility document for details on using a build facility to quickly perform these tasks.

To rebuild the entire sample from scratch, you can simply execute:

build all

From the directory install_dir/ias/ias-samples/bank/src/

On UNIX, you might need to modify your PATH to ensure that install_dir/ias/bin is included to pickup the build script.


Clustering the Bank Application

Using the Bank application, one can demonstrate the power and advantages of the iPlanet Application Server session replication and failover features. Load balancing, multiple JVMs, HttpSession replication and failover features can enhance the performance and availability of the Bank application. This section provides some pointers as to how one can configure the Bank application to take advantage of iPlanet clustering features without making application level changes. It is assumed that you have successfully deployed Bank to a single application server and have exercised the simple cluster servlet described in the Cluster Sample Applications.

To ensure that Bank makes the most use of a cluster environment, we must make sure that it is configured with these key settings:

To ensure that Bank functions properly in a clustered environment, both the pre-built bank.ear file and the EAR file resulting from the assembly instructions in this document contain these "sticky" and "distributed" session settings. The only other special considerations for deploying Bank 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 plugins 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. For the sample, you can simply rerun the database setup script on each system in the cluster. Alternatively, you can use Deployment Tool to remotely register JDBC datasources.

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 Bank 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 Bank in the same cluster environment.

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

2. Run setup_ora.sh/.bat file on each server in the cluster to register the JDBC datasource with each application server instance.

3. Populate the directory server with the Bank users. Since the directory server is shared in the sample cluster, you need to perform the population step only once.

4. 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.

5. Since a the BankService EJB relies on environment settings to point it to the appropriate directory server, you must modify the environment settings such that the EJB points to the common directory server used across the cluster. The default host name of localhost will not work properly when deploying Bank to multiple machines in a cluster.

6. 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.

Exercise the same failure scenarios as those used in the Cluster Servlet sample against the Bank sample.

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