Sun Java System logo
Session Storage Sample Application for Enterprise Edition

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

This sample application document contains the following sections:

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 /src 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 (war), do the following:
    •  
    • Go to the ee-samples/sessionstorage/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/sessionstorage/src directory

    •  
    • Execute the command $AS_HOME/bin/asant ear
      •  
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 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/sessionstorage/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/sessionstorage

     
  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 SessionStorage --instance <instance_name> sessionstorage.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 (SessionStorage.war)
    Click OK.

     
  9. Enter SessionStorage as application name and  as context root
  10. Click OK.
If the deployment processes correctly, you will see the original panel displaying 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.

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

SessionStorage <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/sessionstorage/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>/SessionStorage


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
 


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/sessionstorage/src:

        asant javadocs
 

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

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 February 14, 2003