Session Storage Sample Application for Enterprise Edition

Samples Index

> Session Storage Sample Application for Enterprise Edition

> This document describes how to utilize the Session Storage sample application in conjunction with Sun Java (tm) System Application Server Enterprise Edition 8.1 2005Q1.

> This sample application document contains the following sections:

> - Overview
> - Compiling and Assembling the Application
> - Deploying the Sample Application
> - Running the Sample Application
> - Troubleshooting
> Overview

> The session storage sample application demonstrates how session persistence scopes and frequencies affect the server performance with different settings. The application has to be deployed to all instances in the cluster and configuration should be set in the load balancer in order for session persistence and failover to work.

> There are two different modes for persistence frequency: web-method and time-based. The default sun-web.xml used web-method mode.
> To use time-based mode, copy file timebased-sun-web.xml to sun-web.xml under sessionstorage-war/web/WEB-INF diectory and then rebuild the sample.

> There are three different modes for persistence scope: session, modified-session, and modified-attribute. The default used session mode.
> To use other modes, copy file modifiedsession-sun-web.xml or modifiedattribute-sun-web.xml to sun-web.xml and the rebuild the sample.

> Compiling and Assembling the Application

> This section contains instructions to build and assemble the Session Storage 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, do the following:
> - Go to the ee-samples/highavailability/apps/sessionstorage directory
> - Execute the command <install_dir>/bin/asant

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

> Deploying the Sample Application

> In this section, you will learn how to deploy the Session Storage 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 EAR 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 SessionStorage.ear file is an Enterprise Archive (EAR) type file.

> Deploying the pre-built SessionStorage.ear 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
> cd <install_dir>/samples/ee-samples/highavailability/apps/sessionstorage
> 2. Run asant using deploy task
> <install_dir>/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 cluster 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
> cd <install_dir>/samples/ee-samples/highavailability/apps/sessionstorage
> 2. Execute asadmin to deploy application to the application server cluster. For example:
> <install_dir>/bin/asadmin deploy -user <adminuser> -password <adminpassword> --host <DAShost> --port <DASport> --availabilityenabled=true --target <cluster-name> SessionStorage.ear
> Where <adminuser> is the Domain Administration Server's admin username, <adminpassword> is the admin user's password, <host> is the machine on which Domain Administration Server is installed and running, <port> is port at which Domain Administration Server is running and target> is the application cluster on which the sample application is to be deployed.

> 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 Enterprise Archive (EAR) 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:
> https://<DAShost>:<DASport>
> 2. Enter the server administrator's username and password to access the admin server.
> 3. On the left panel, navigate the tree by clicking on the following:
> Cluster -> <cluster-name>
> 4. On the right panel, the Applications tab will be pre-selected. In the " --New--" drop down list select "Enterprise Application". The "Deployment Page" will load in the right frame.
> 5. Set "Upload" to "Yes" and click on `Browse' to select the .ear file (from disk) to be deployed (SessionStorage.ear) Click `Next' on the top right hand corner of the frame. .
> 6. Enter the application name as SessionStorage. Enable "Availability" checkbox and add a target cluster to deploy the application on from the displayed list in the "Targets" section.
> 7. Click OK

> If the deployment succeeds, you will see the `Enterprise Applications' panel and under `Deployed Enterprise Applications' you will see the SessionStorage 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.

> <install_dir>/bin/asadmin list-components --user <adminuser> --password <adminpassword> --host <DAShost> --port <DASport> <clustername>

> For example:

> <install_dir>/bin/asadmin list-components --user admin --password admin123 --host localhost --port 4848 cluster1

> You should see output similar to what is displayed below:

> SessionStorage <j2ee-application>

> Undeploying the Sample Application

> To undeploy the sample application, do the following:

> 1. Go to the <install_dir>/samples/ee-samples/highavailability/apps/SessionStorage directory
> 2. Execute the command asant undeploy

> Running the Sample Application

> In order to run the sample application, you must first do the following:
> - Compile, Assemble and Deploy the application as described in the previous sections Compiling and Assembling the Application, and Deploying the Sample Application.
> You are now ready to run the sample application by doing the following: On your browser go to the url : http://<Whost>:<Wport>/SessionStorage
> Where `Whost` is the hostname of webserver having the loadbalancer plugin setup and configured and `Wport` is the port at which that webserver is running.

> The images from running the application:

> Figure 1 - index page

> Figure 2 - Single Attribute selected

> Figure 3 - Single attribute session with specified object size

> Figure 4 - Input screen for multiple attributes session

> Now, stop the instance that served the request. (See Running the sample Applications section here to see how to do this). After the instance is shut down completely, click on UpdateAttribute button (figure 5). You'll see that the Update Attributes form will come up with the Name and Sex fields set previously (Figure 6). Modify the Salary or the phone number and click on Modify data to set the new values in the session (Figure 7).

> Figure 5 - Data for multiple attributes session

> Figure 6 - Enter data for updated attributes

> Figure 7 - Session data after attributes are updated

> Generating javadocs

> To better understand sample application source code, you may refer to the related javadocs.

> To generate javadocs, run the following command from samples/ee-samples/highavailability/apps/sessionstorage:

> asant javadocs

> After javadocs are generated, you may access them at samples/ee-samples/highavailability/apps/sessionstorage/javadocs/index.html.

> Troubleshooting

> - If you encounter problems when running the application, review the log files at <install-dir>/domains/domain1/logs/server.log and <install_dir>/nodeagents/<agent-name>/<instance-name>/logs/server.log (also check which instance served the request) 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 © 2004 Sun Microsystems, Inc. All rights reserved.

Last Updated June 13, 2004