![]() |
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
- Overview
- Compiling and Assembling the Application
- Deploying the Sample Application
- Running the Sample Application
- Troubleshooting
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.
Deploying the Sample Application
- 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
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 DeploymentSince 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.
- Go to the src directory of the sample
- cd $AS_HOME/samples/ee-samples/clusterjsp/src
- Run asant using deploy task
- $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 commandWhere <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).
- Go to the root of the sample directory
- cd $AS_HOME/samples/ee-samples/clusterjsp
- Execute asadmin to deploy application to the local application server instance. For example:
- $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
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 DeploymentSince 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.
If the deployment processes correctly, you will see the original panel displaying the clusterjsp application as deployed.
- From your web browser, access the Sun Java (tm) System Application Server by entering the URL. For example:
- http://<server-host>:<admin-port>
- Enter the server administrator's username and password to access the admin server.
- On the left panel, navigate the tree by clicking on the following:
- App Server Instances->server1->Applications->Web Apps
- On the right panel, click on the Deploy button.
- Enter the File Path to select the file (from disk) to be deployed (clusterjsp.war)
- Click OK.
- Enter the application name as clusterjsp and context root as clusterjsp
- Click OK.
Verifying DeploymentAs 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 server1You 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 ApplicationTo undeploy the sample application, do the following:
- Go to the $AS_HOME/samples/ee-samples/clusterjsp/src directory
- Execute the command asant undeploy
- Reconfigure the server instance.
$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:
- Compile, Assemble and Deploy the application as described in the previous sections Compiling and Assembling the Application, and Deploying the Sample Application.
On your browser go to the url : http://<host>:<port>/clusterjsp
The image from running the application:
![]()
- 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.