Title
Configure session failover in an OC4J cluster (10g)

Date
2008-06-29

Summary
The steps below describe how to create an OC4J cluster and test Java session failover in Oracle Application Server 10g R3.

Details
1. a. Create a Topology Network Configuration.
b. Create the same OC4J container name on all application server.
c. Create a GROUP and assign all OC4J containers to the same group name.

2. Add the <distributable/> flag to the WEB-INF/web.xml file in each application.

3. Add the following configuration to each orion-application.xml file in each application. The configuration below assumes node-to-node configuration. Refer to Oracle documentation for details on multicast.
<cluster allow-colocation="false">
  <replication-policy trigger="onShutdown" scope="allAttributes"/>
  <protocol>
    <peer>
      <opmn-discovery/>
    </peer>
  </protocol>
</cluster>

4. Use the following JSP to test session failover:
<%@page session="true" %>
<%
  if (request.getParameter("action") != null) {
    if (request.getParameter("action").equals("set")) {
      session.putValue("test",(String)session.getId());
    } else if (request.getParameter("action").equals("unset")) {
      session.putValue("test",null);
    }
  }
  if (session.getValue("test") == null) {
    out.println("Session variable 'test' is NULL.<br>");
  } else {
    out.println("Session variable 'test' has the session id ");
    out.println("value of: " + session.getValue("test") + ".<br>");
  }
%>

<br>
<a href="test.jsp?action=set">Set session variable</a><br>
<a href="test.jsp?action=unset">Remove session variable</a><br>
<a href="test.jsp">Refresh page</a><br>

Applicable Versions
Oracle Application Server 10g (10.1.3)

References
http://download.oracle.com/docs/cd/B32110_01/core.1013/b32201/aa.htm
Ahmed Aboulnaga

.com .com