24 Installing Coherence*Web Session Management Module

This chapter applies to the Coherence*Web Session Management Module in Coherence release 3.0 or later. This Session Management Module is very different and much more comprehensive than the module provided with Coherence releases before Release 2.3. Since we chose to not include the previous version's module jars and documentation in release 2.3 to avoid confusion, if you are looking for information on how to install pre-Release 2.3 module, please refer to the documentation and the User Guide included with the doc directory of the software distribution for the release level you are installing.

24.1 Supported Web Containers

Table 24-1 summarizes the Web containers supported by the Coherence*Web Session Management Module and the installation information specific to each supported Web container. The table also describes where you can find detailed installation instructions.

Table 24-1 Web Containers Supported by Coherence*Web

Application Server Server Type Alias* See this Installation Section

Apache Tomcat 4.1.x

Tomcat/4.1.x

"General Instructions for Installing the Session Management Module"

Apache Tomcat 5.0.x

Tomcat/5.0.x

"General Instructions for Installing the Session Management Module"

Apache Tomcat 5.5.x

Tomcat/5.5.x

"General Instructions for Installing the Session Management Module"

BEA WebLogic 8.x

WebLogic/8.x

"Installing the Session Management Module on BEA WebLogic 8.x"

BEA WebLogic 9.x

WebLogic/9.x

"Installing the Session Management Module on BEA WebLogic 9.x"

BEA WebLogic 10.x

WebLogic/10.x

"Installing the Session Management Module on BEA WebLogic 10.x"

BEA WebLogic Portal 8.1.6+

WebLogic/Portal/8.1.6+

"Installing the Session Management Module on BEA WebLogic Portal 8.1.6+"

Caucho Resin 3.0.x

Resin/3.0.x

"Installing the Session Management Module on Caucho Resin® 3.0.x"

IronFlare Orion 2.0.x

Orion/2.0.x

"General Instructions for Installing the Session Management Module"

IBM WebSphere 5.x

WebSphere/5.x

"General Instructions for Installing the Session Management Module"

IBM WebSphere 6.x

WebSphere/6.x

"General Instructions for Installing the Session Management Module"

JBoss Application Server

Jetty/4.2+ or Tomcat/*

"General Instructions for Installing the Session Management Module"

Jetty 4.2.14 and later

Jetty/4.2+

"General Instructions for Installing the Session Management Module"

New Atlanta ServletExec 5.0

ServletExec/5.x

"General Instructions for Installing the Session Management Module"

Oracle OC4J 10.1.2.x

Oracle/10.1.2.x

"Installing the Session Management Module on Oracle® OC4J 10.1.2.x"

Oracle OC4J 10.1.3.x

Oracle/10.1.3.x

"General Instructions for Installing the Session Management Module"

Sun ONE 6.1, 7 and 8.1

SunONE

"General Instructions for Installing the Session Management Module"


Notes:

* The server type alias passed to the Coherence*Web installer by using the -server command line option.

24.2 General Instructions for Installing the Session Management Module

To enable Coherence*Web in your Java EE application, you need to run a ready to deploy application (recommended) through the automated installer before deploying it. The automated installer prepares the application for deployment.

To install Coherence*Web for the Java EE application you are deploying:

  • Make sure that the application directory, .ear file or .war file are not being used or accessed by another process.

  • Change the current directory to the Coherence library directory (%COHERENCE_HOME%\lib on Windows and $COHERENCE_HOME/lib on UNIX).

  • Make sure that the paths are configured so that the Java command will run.

  • Complete the application inspection step by running the following command and specifying the full path to your application and the name of your server found in the Table 24-1 (replacing the <app-path> and <server-type> with them in the command line)

    java -jar webInstaller.jar <app-path> -inspect -server:<server-type>
    

    The system will create (or update, if it already exists), the coherence-web.xml configuration descriptor file for your Java EE application in the directory where the application is located. This configuration descriptor contains the default Coherence*Web settings for your application recommended by the installer. You may proceed to the install step or review and modify the settings, based on your requirements, before running the install step. For example, you can enable certain features by setting the context-param options in the coherence-web.xml configuration descriptor:

    • This setting will cluster all ServletContext (global) attributes so that servers in a cluster will share the same values for those attributes, and will also receive the events specified by the Servlet Specification when those attributes change:

      Table 24-2 Settings to Cluster ServletContext Attributes

      Parameter Value

      param-name

      coherence-servletcontext-clustered

      param-value

      true


    • This setting allows an application to enumerate all of the sessions that exist within the application, or to obtain any one of those sessions to examine or manipulate:

      Table 24-3 Settings to Enumerate All Sessions in the Application

      Parameter Value

      param-name

      coherence-enable-session-context

      param-value

      true


    • This setting enables you to increase the length of the HttpSession ID, which is generated using a SecureRandom algorithm; the length can be any value, although in practice it should be small enough to fit into a cookie or a URL (depending on how session IDs are maintained.) Increasing the length can decrease the chance of a session being purposefully hijacked:

      Table 24-4 Settings to Increase Length of HTTPSession ID

      Parameter Value

      param-name

      coherence-session-id-length

      param-value

      32


    • By default, the HttpSession ID is managed in a cookie. If the application supports URL encoding, set the following option to enable it:

      Table 24-5 Settings to Support URI Encoding

      Parameter Value

      param-name

      coherence-session-urlencode-enabled

      param-value

      true


      After double-checking that these changes have been made, save the file and exit the editor; remember to return back to the Coherence library directory if you are working from a shell or command line.

  • Go through the Coherence*Web application installation step by running the following command and specifying the full path to your application (replacing the <app-path> with it in the command line):

    java -jar webInstaller.jar <app-path> -install
    

    The installer requires a valid coherence-web.xml configuration descriptor for its use in the same directory in which the application is located.

  • Deploy the updated application and verify that everything functions as expected, using the load balancer if necessary. Please remember that the load balancer is only intended for testing and should not be used in a production environment.

24.3 Installing the Session Management Module on BEA WebLogic 8.x

The following additional steps are required when installing the Coherence*Web Session Management Module into a BEA WebLogic 8.x server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory:

    On Windows:

    move web-install\coherence-web.jar .
              rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
              rmdir web-install
    
  2. For each WebLogic 8.x install that will be running in the server cluster, update the libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <wls-home-path> -install
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\bea\weblogic8\server -install
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" and specify WebLogic/8.x for the server type.

24.4 Installing the Session Management Module on BEA WebLogic 9.x

The following are additional steps to take when installing the Coherence*Web Session Management Module into a BEA WebLogic 9.x server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory:

    On Windows:

    move web-install\coherence-web.jar .
    rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
    rmdir web-install
    
  2. For each WebLogic 9.x install that will be running in the server cluster, update the libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <wls-home-path> -install
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\bea\weblogic9\server -install
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" and specify WebLogic/9.x for the server type.

24.5 Installing the Session Management Module on BEA WebLogic 10.x

The following are additional steps to take when installing the Coherence*Web Session Management Module into a BEA WebLogic 10.x server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory:

    On Windows:

    move web-install\coherence-web.jar .
    rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
    rmdir web-install
    
  2. For each WebLogic 10.x install that will be running in the server cluster, update the libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <wls-home-path> -install
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\bea\weblogic10\server -install
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" and specify WebLogic/10.x for the server type.

24.6 Installing the Session Management Module on BEA WebLogic Portal 8.1.6+

The following are additional steps to take when installing the Coherence*Web Session Management Module into a BEA WebLogic Portal 8.1.6+ server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory: On Windows:

    move web-install\coherence-web.jar .
    rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
    rmdir web-install
    
  2. For each WebLogic Portal 8.1.6+ install that will be running in the server cluster, update the WebLogic server libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <wls-home-path> -install
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\bea\weblogic81\server -install
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" on each Portal web application, and specify WebLogic/Portal/8.1.6+ for the server type.

  4. Add the following line to the netuix-config.xml file found in the WEB-INF directory in each Portal web application that has Coherence*Web installed (immediately before the <pageflow> configuration element):

    <servlet-filters-for-skeleton-jsps enable="true"/>
    

24.7 Installing the Session Management Module on Caucho Resin® 3.0.x

The following are additional steps to take when installing the Coherence*Web Session Management Module into a Caucho Resin server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory:

    On Windows:

    move web-install\coherence-web.jar .
    rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
    rmdir web-install
    
  2. For each Resin install that will be running in the server cluster, update the libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <resin-home-path> -install 
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\opt\resin30 -install
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" and specify Resin/3.0.x for the server type.

24.8 Installing the Session Management Module on Oracle® OC4J 10.1.2.x

The following are additional steps to take when installing the Coherence*Web Session Management Module into a Oracle OC4J 10.1.2.x server:

  1. From within the Coherence library directory, extract the coherence-web.jar from the webInstaller.jar:

    jar -xvf webInstaller.jar web-install/coherence-web.jar
    

    This will extract the coherence-web.jar file into a subdirectory named web-install. Use the following commands to move the coherence-web.jar file up one level into the library directory:

    On Windows:

    move web-install\coherence-web.jar .
    rmdir web-install
    

    On UNIX:

    mv web-install/coherence-web.jar .
    rmdir web-install
    
  2. For each OC4J install that will be running in the server cluster, update the libraries using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command typed in on one line):

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller <oc4j-home-path> -install 
    

    For example, on Windows:

    java -cp coherence.jar;coherence-web.jar
                 com.tangosol.coherence.servlet.WebPluginInstaller
                 C:\opt\oracle101\j2ee\home
    
  3. Follow the steps in "General Instructions for Installing the Session Management Module" and specify Oracle/10.1.2.x for the server type.

24.9 How the Coherence*Web Installer Instruments a Java EE Application

During the inspect step, the Coherence*Web Installer performs the following tasks:

  1. Generates a template coherence-web.xml configuration file that contains basic information about the application and target web container along with a set of default Coherence*Web configuration context parameters appropriate for the target web container. If an existing coherence-web.xml configuration file exists (for example, from a previous run of the Coherence*Web Installer), the context parameters in the existing file are merged with those in the generated template.

  2. Enumerates the JSPs from each web application in the target Java EE application and add information about each JSP to the coherence-web.xml configuration file.

  3. Enumerates the TLDs from each web application in the target Java EE application and add information about each TLD to the coherence-web.xml configuration file.

During the install step, the Coherence*Web Installer performs the following tasks:

  1. Creates a backup of the original Java EE application so that it can be restored during the uninstall step.

  2. Add the Coherence*Web configuration context parameters generated in step (1) of the inspect step to the web.xml descriptor of each web application contained in the target Java EE application.

  3. Unregisters any application-specific ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener, and HttpSessionAttributeListener classes (including those registered by TLDs) from each web application.

  4. Registers a Coherence*Web ServletContextListener in each web.xml descriptor. At runtime, the Coherence*Web ServletContextListener will propagate each ServletContextEvent to each application-specific ServletContextListener.

  5. Registers a Coherence*Web ServletContextAttributeListener in each web.xml descriptor. At runtime, the Coherence*Web ServletContextAttributeListener will propagate each ServletContextAttributeEvent to each application-specific ServletContextAttributeListener.

  6. Wraps each application-specific Servlet declared in each web.xml descriptor with a Coherence*Web SessionServlet. At runtime, each Coherence*Web SessionServlet will delegate to the wrapped Servlet.

  7. Adds the following directive to each JSP enumerated in step (2) of the inspect step:

    <%@ page extends="com.tangosol.coherence.servlet.api22.JspServlet" %>
    

During the uninstall step, the Coherence*Web Installer replaces the instrumented Java EE application with the backup of the original version created in step (1) of the install process.

24.10 Testing HTTP Session Management (without a dedicated loadbalancer)

Coherence comes with a light-weight software load balancer; it is only intended for testing purposes. The load balancer is very useful when testing functionality such as Session Management and is very easy to use.

  1. Start multiple application server processes, on one or more server machines, each running your application on a unique IP address and port combination.

  2. Open a command (or shell) window.

  3. Change the current directory to the Coherence library directory (%COHERENCE_HOME%\lib on Windows and $COHERENCE_HOME/lib on UNIX).

  4. Make sure that the paths are configured so that the Java command will run.

  5. Start the software load balancer with the following command lines (each of these command lines makes the application available on the default HTTP port, which is port 80):To test load-balancing locally on one machine with two application server instances on ports 7001 and 7002:

    java -jar coherence-loadbalancer.jar localhost:80 localhost:7001 localhost:7002
    

    To run the load-balancer locally on a machine named server1 that load balances to port 7001 on server1, server2 and server3:

    java -jar coherence-loadbalancer.jar server1:80 server1:7001 server2:7001 server3:7001
    

    Assuming the above command line, an application that previously was accessed with the URL http://server1:7001/my.jsp would now be accessed with the URL http://server1:80/my.jsp or just http://server1/my.jsp. The following command line options are supported:

    Table 24-6 Command Line Options to Test HTTP Session Management

    Option Description

    -backlog

    Sets the TCP/ IP accept backlog option to the specified value, for example:-backlog=64

    -random

    Specifies the use of a random load-balancing algorithm (default)

    -roundrobin

    Specifies the use of a round-robin load-balancing algorithm

    -threads

    Uses the specified number of request/ response thread pairs (so the total number of additional daemon threads will be two times the specified value), for example:-threads=64


    Make sure that your application uses only relative re-directs or the address or the load-balancer.