} }

 Files   Build & Configure   Run   Troubleshoot   Related Topics 

 

About the Example

This example demonstrates HTTP Session state replication, the WebLogic Server feature that enables the failover mechanism. You will set up the "HTTP Cluster Servlet" on a stand-alone Managed Server to proxy client requests to Managed Servers in a cluster. You will see an HTTP session fail over from one Managed Server to another when the operation of the server instance hosting the session is interrupted.

The instructions that follow guide you through the steps to:


 

Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/src/examples/cluster/sessionrep/inmemrep/

Where MW_HOME is the directory containing your WebLogic Server installation.

File

Click source files to view code.

Description

build.xml Ant build file that contains targets for building and running the example.
Session.jsp Java Server Page JSP to demonstrating the use of replication of a session in memory, using a cluster-enabled proxy server.
web.xml The Java EE standard Web application deployment descriptor.
weblogic.xml The WebLogic Server-specific Web application deployment descriptor.

 

Building and Configuring the Example

 

Prerequisites

Before working with this example:

  1. Install WebLogic Server, including the examples.
  2. DO NOT start the examples server, this will conflict with the server running your cluster because they will both be using the same port
  3. Set up your environment.

Configure a cluster

  1. Configure a cluster, consisting of an Administration Server and two Managed Servers as described in the Examples Clustering Guide. When following the instructions in that guide, also do the following:
    1. On the Configure Managed Servers page, configure an additional Managed Server instance that will not be part of the cluster to listen on a seperate port from the admin and managed server clusters (for example 7005). The non-clustered server will be used as a proxy server. (These instructions assume that the server name is httpProxy.) DO NOT select a proxy server for the cluster.
    2. On the Assign Servers to Clusters page, do add all servers to the cluster except for the additional non-clustered server you just created.
    3. Finish creating the new domain as described in the Examples Clustering Guide. Start the proxy server in the same manner in which you start the other managed servers.
  2. Start the Administration Server according the instructions in Examples Clustering Guide
  3. Start the Administration Console by pointing your browser to the IP address and port number that you defined for the Administration Server:

    http://listen_address:listen_port/console

Edit deployment descriptor for the HTTP Cluster Servlet

The HTTP Cluster Servlet is included with your WebLogic Server installation. In order to deploy the the cluster to your proxy server, your configuration must indicate how the proxy is locate the member servers. This process is described below.

What you should understand

Two deployment descriptors for the HTTP Cluster Servlet are located in SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep\defaultProxyApp\WEB-INF: weblogic.xml and web.xml. The defaultProxyApp directory will be deployed on the proxy server as an application later. The deployment descriptors in this directory structure provide the configuration for the proxy server.

weblogic.xml sets the context-root deployment parameter to "/". Setting context-root to "/" has the effect of making the proxy servlet the default web application for the proxy server. For this example, you do not need to modify weblogic.xml.

web.xml defines a variety of parameters that specify the location and behavior of the HTTP Cluster Servlet. These notes will help you understand the contents of web.xml:

What you should do

  1. Open web.xml, located in SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep\defaultProxyApp\WEB-INF with an editor.
  2. Edit the value specified for the WebLogicCluster parameter to reflect the Listen Addresses and Listen Ports of the Managed Servers in your cluster. In the following string, replace the IP addresses and port numbers with the Listen Address and Listen Port combinations for the two Managed Servers in your cluster:

    <param-name>WebLogicCluster</param-name>
    <param-value>localhost:7010|localhost:7020</param-value>

  3. Save your changes.

Deploying the HTTP Cluster Servlet

Deploy the defaultProxyApp by deploying it as an application on the proxy (httpProxy) server using the admin console's deployment utility.

  1. Start the Administration Server.
  2. In the left pane of the Administration Console, select the Deployments node.
  3. Click on the "Lock and Edit" button of the Change Center.
  4. In the right pane, click Install.
  5. In the Install Application Assistant module section of the right pane, browse to this directory: SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep\
  6. Select the defaultProxyApp file and click Next.
  7. For the choose targeting style dialogue, select Install this as an Application.
  8. In the Select deployment targets dialogue, check the box next to the proxy server (httpProxy) only. Click Next.
  9. On the Optional Settings page, the name of the application is set to defaultProxyApp. Click Finish.
  10. In the left column in the Change Center, click Activate Changes.
  11. In the right pane, click on the check box next to defaultProxyApp and click on the Start -> Servicing all Requests button from the table header to start the defaultProxyApp.
  12. Click Yes to confirm the activation.

 

Configure WebLogic Server

  No special configuration is required for this example

 

Build and Deploy the Example

  1. Open a new command shell.
  2. Set up your development shell as described in Examples Basic Steps.
  3. Change directory to SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep.
  4. Use the build script to compile the example by typing ant. This builds the JSP and descriptors, and package them in InMemRepClient.war.

Deploying the Example

Start any of your server instances that are not running. For instructions, see Examples Clustering Guide.

Install the InMemRepClient.war that was created when you built the example:

  1. Start the Administration Server.
  2. In the left pane of the Administration Console, expand the Deployments node.
  3. Click on the "Lock and Edit" button of the Change Center.
  4. In the right pane, click Install.
  5. In the Install Application Assistant module section of the right pane, browse to this directory: SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep\build
  6. Select the InMemRepClient.war file and click Next.
  7. Select Install this deployment as an application and click Next.
  8. In the Select deployment targets dialogue, check the box next to your cluster in the table labeled Clusters and the All Servers in the cluster option. Click Next.
  9. On the Optional Settings page, the name of the application is set to InMemRepClient. Click Finish.
  10. If the deployment succeeded, the table on the Deploy tab shows InMemRepClient in the table.
  11. In the left column in the Change Center, click Activate Changes.
  12. In the right pane, click on the check box next to InMemRepClient and click on the Start -> Servicing all Requests button from the table header to start the InMemRepClient.
  13. Click Yes to confirm the activation.

 

 


 

Running the Example

  1. Complete the steps in the "Prepare the Example" section.
  2. From the Control Tab of the Deployments screen, click on the check box next to InMemRepClient and defaultProxyApp, and click on the Start -> Servicing all Requests button from the table header to start them.
  3. Click the Yes button to confirm the activation.
  4. Open a new browser window.
  5. Point your browser to http://listen_address:listen_port/InMemRepClient/Session.jsp , substituting the listen address and port of the proxy Server. For example: http://localhost:7005/InMemRepClient/Session.jsp
  6. A page called Cluster Replication of an HTTP Session in Memory is displayed. Note that the page displays the name of the Managed Server that is hosting the session.
  7. Enter some values into the fields on the page, clicking Save to save the values.
  8. Stop the Managed Server running the JSP. You can do this by closing the command shell in which you started that server instance.
  9. Use the View-->Refresh command in your browser to redisplay the page. Note that the session is now running on a different Managed Server, and your data has not been lost.

 

Troubleshooting

 

Can the HTTP Cluster Servlet see your clustered servers?

To check which Managed Servers in your cluster the HTTP Cluster Servlet can see, point your browser to the following URL, substituting the IP address and port of the proxy server:

http://localhost:7005/foo.jsp?__WebLogicBridgeConfig

The page will display a list of the Managed Servers that the proxy servlet can see, and the values of parameters that govern the operation of the proxy servlet:

Query String: __WebLogicBridgeConfig

General Server List:

  1. localhost:7010:443
  2. localhost:7020:443

Make sure all servers instances have unique address/port combinations

Each of the servers you configure must have a unique combination of Listen Address and Listen Port. It is assumed that you are running all server instances on the same machine. In that case, all server instances will have the same Listen Address, and each will have a different Listen Port.

When all else fails, restart

If you are having problems try rebooting all your servers, some of the changes you made while configuring your setup may not have been persisted to the configuration file.

Make sure that defaultProxyApp is the default web application for the proxy server

If you get a page not found error when you try to run the example, make sure that weblogic.xml is in SAMPLES_HOME\server\examples\src\examples\cluster\sessionrep\inmemrep\defaultProxyApp\WEB-INF, and that it sets the context-root deployment parameter to "/".


 

Related Topics