Sun Java System logo
Cluster JSP Sample Application for Enterprise Edition

 
Cluster - HA JSP Sample Application for Enterprise Edition
 

This document describes how to utilize the cluster JSP sample application in conjunction with Sun Java (tm) System Application Server Enterprise Edition 7 2004Q2.

This sample application document contains the following sections:

Overview

The cluster JSP sample application demonstrates how a request to a JSP may be shared or load balanced between all server instances in a cluster, with the HttpSession or "shopping cart" information surviving an abnormal condition in any server in a cluster.  Simulated outages will demonstrate both failover and high availability.  The Load Balancer will distribute requests to all instances in the cluster. It has the ability to forward a request to a healthy instance if it detects that the target instance is unavailable.
 
 

Compiling and Assembling the Application



This section contains instructions to build and assemble the Cluster JSP sample application.

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

     
  • To rebuild the sample as J2EE module (war), do the following:
    •  
    • Go to the ee-samples/clusterjsp/src directory

    •  
    • Execute the command $AS_HOME/bin/asant

    •  

       
       
       

      The default target core will be executed to compile java files and rebuild the WAR file.
       

  • To build the sample as J2EE application (ear), do the following:
    •  
    • Go to the ee-samples/clusterjsp/src directory

    •  
    • Execute the command $AS_HOME/bin/asant ear
      •  
Deploying the Sample Application

In this section, you will learn how to deploy the Cluster JSP sample application.

Select one of the following approaches to deploying the application:

  • Command Line-based Deployment describes how to manually register the application in Sun Java (tm) System Application Server using a Command Line Interface (CLI). This is the fastest means of deploying the sample application.

  •  
  • GUI-based Deployment describes how to use the Sun Java (tm) System Application Server Administration Tool to deploy the sample application.

  •  


Command Line-based Deployment

Since a complete WAR file is supplied, the fastest means of setting up the application is to use the command line utilities described in this section.

The pre-built clusterjsp.war file is a Web Archive (WAR) file of the application.

Deploying the pre-built clusterjsp.war file is simple. Deploy either Using the asant script or by Using the asadmin command.
 

Using the asant script

  1. Go to the src directory of the sample
  2. cd $AS_HOME/samples/ee-samples/clusterjsp/src

     
  3. Run asant using deploy task
  4. $AS_HOME/bin/asant deploy

Note If you run asant deploy for the first time, you'll be asked to enter your Sun Java (tm) System appserver host name, admin port, admin user, password and instance name The subsequent runs of asant will get this information from a properties file create after the first time you ran asant deploy


Using the asadmin command
  1. Go to the root of the sample directory
  2. cd $AS_HOME/samples/ee-samples/clusterjsp

     
  3. Execute asadmin to deploy application to the local application server instance. For example:
  4. $AS_HOME/bin/asadmin deploy -u <admin_username> -w <admin_password> -H <host> -p <adminserver_port> --type web --name clusterjsp --instance <instance_name> clusterjsp.war
Where <admin_username> is application server admin user name, <admin_password> is the admin password, <host> is the machine on which the application server is installed, <adminserver_port> is admin server port of the application server, and <instance_name> is the application server instance name (e.g. server1).

If you would like to verify the registration of the application, you may proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.



GUI-based Deployment

Since a pre-built Web Archive (WAR) file for the sample application is included with the application server, you can use the Sun Java (tm) System Application Server Administration Tool to quickly deploy it to the Application Server.

     
  1. From your web browser, access the Sun Java (tm) System Application Server by entering the URL. For example:
  2. http://<server-host>:<admin-port>

     
  3. Enter the server administrator's username and password to access the admin server.

  4.  
  5. On the left panel, navigate the tree by clicking on the following:
  6. App Server Instances->server1->Applications->Web Apps

     
  7. On the right panel, click on the Deploy button.
  8. Enter the File Path to select the file (from disk) to be deployed (clusterjsp.war)
    Click OK.

     
  9. Enter the application name as clusterjsp and context root as clusterjsp
  10. Click OK.

     
If the deployment processes correctly, you will see the original panel displaying the clusterjsp application as deployed.



Verifying Deployment

As an optional step, you can use the Sun Java (tm) System Application Server Administration Tool to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.

To verify the registration of the application, do the following:

Execute the command asadmin list-components to display applications deployed with a server instance.

$AS_HOME/bin/asadmin list-components -u <admin_username> -w <admin_password> -H <host> -p <adminserver_port> <instance_name>

For example:
$AS_HOME/bin/asadmin list-components -u admin -w adminadmin -H west -p 4848 server1

You should see output similar to what is displayed below:

TradeSample <application>

clusterjsp <web>
There are no standalone EJB modules
There are no connector modules


Undeploying the Sample Application

To undeploy the sample application, do the following:

  1. Go to the $AS_HOME/samples/ee-samples/clusterjsp/src directory

  2.  
  3. Execute the command asant undeploy

  4.  
  5. Reconfigure the server instance.

  6. $AS_HOME/bin/asadmin reconfig -u <admin_username> -w <admin_password> -H <host> -p <adminserver_port> <instance_name>


Running the Sample Application



In order to run the sample application, you must first do the following: You are now ready to run the sample application by doing the following:
    On your browser go to the url : http://<host>:<port>/clusterjsp


The image from running the application:


 



 
 

Troubleshooting


  • If you encounter problems when running the application, review the log files at <install-dir>/domains/domain1/<server-instance>/logs/server.log to learn what exactly went wrong.

  •  
  • To redeploy the sample, please undeploy the sample first. Use the commands asant undeploy, asant clean and then asant all.

Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
Last Updated May14, 2003