Getting Started with Coherence*Web in WebLogic Server 12.1.2


Coherence*Web is a great feature which allows you to store your HTTP sessions in a Coherence Cluster.  Doing this allows your to de-couple the HTTP sessions from your JVM’s that are running your web apps, (which can free up JVM memory) and take advantage of the RASP (Reliability, Availability, Scalability and Performance) capabilities of Coherence for storage.

With this separation you can also more easily scale and manage and your HTTP session tier as well as utilise the wide array of session management options that Coherence*Web provides.

What I’d like to show you here is how to configure Coherence*Web in WebLogic Server 12.1.2 and deploy a basic web application that utilises this.

For more detailed information on Coherence*Web and the options available, see


For this example, I’m assuming you already have installed WebLogic Server 12.1.2 and created a domain with node manager running.

If you are not familiar with how to do this, then you can use one of my posts here as a starting point or see the product documentation here.

We are going to create two WebLogic Server Clusters and a Coherence cluster into which we shall place both WLS clusters. This will ensure that the manages servers in both WLS clusters are associated with a common set of Coherence caching services

  • StorageTier – 2 Coherence managed servers storage1 and storage2. This tier will hold the HTTP session data.
  • ClientTier – 2 regular application managed servers client1 and client2 – We will deploy our application to this tier.

Typically you would have multiple servers in each tier and have a load balancer in front, but for this example, we will just 2 which is the minimus to demonstrate session fail-over.

Once you have your AdminServer and node manager up and running, login to the console to carry out the following steps.

1. Create a Coherence Cluster

  • Navigate to Domain Structure then Environment and click on Coherence Clusters.
  • Give it a name and leave the defaults.  Do not target it the AdminServer as we will target it in a moment.

Coherence Cluster

2. Create the WebLogic Clusters, place both your WLS clusters in the Coherence cluster and configure Coherence storage for each WLS cluster

  • Navigate to the Clusters link and create 2 clusters. StorageTier and ClientTier.
  • Leave the defaults as is.
  • Select the StorageTier cluster and click on the Coherence tab.
  • Select your newly created Coherence cluster and click Save.
  • Select Coherence Web Local Storage Enabled to ensure any managed servers in this cluster store Coherence*Web session data.
  • Click Save to continue.

Storage Tier

  • Select the ClientTier cluster and click on the Coherence tab.
  • Select your newly created Coherence cluster and click Save.
  • De-select Local Storage Enabled and click Save. We don’t want to actually store HTTP sessions in the client tier, but we want to be able to access them.

Client Tier

3. Create Managed Servers to populate each WLS cluster.

Note the managed servers added to each cluster will inherit their Coherence config form the cluster wide values which you set above. This means the Coherence managed servers added to the Storage Tier WLS cluster will be providing session storage while the Regular managed servers in the Client Tier WLS cluster will be coherence clients.

  • Navigate to the Servers link
  • Create a new managed server called client1 and assign it to the ClientTier as well as the machine you created. Set the listener port to 7005.
  • Create a new managed server called storage1 and assign it to the StorageTier as well as the machine you created. Set the listener port to 7007.
  • Clone storage1 and name it storage2 and change the listener port to 7009.
  • Start up you managed servers.

Managed Servers


Now we need to Deploy applications which will demonstrate session fail-over and management features we have configured

  1. ClusterJSP – (optional) shows session failover.
  2. Sample-applications (optional) shows session management features

Deployment 1 ClusterJSP
Deploy ClusterJSP as a directory deployment rather than a archive deployment. This will make modifications of the deployment descriptors easier.  You can download the file required from here.

Deploy the Application

  • Unzip into your WLS domain applications directory (…/user_projects/applications)
    <wls install…>/applications/clusterjsp-ear/clusterjsp-war/WEB-INF/weblogic.xml
  • In the Admin. Console navigate to the Deployments page.
  • Click the Install button and navigate to the applications directory where you should find the clusterjsp-ear directory.
  • Click the select button to the left of the folder and click the Next button at the bottom of the page.
  • Leave Install as application selected and click Next.
  • Select ClientTier cluster and click Next.
  • Leave the defaults and click Finish.

Test the application

  • In a browser access the clusterjsp with the following url: http://yourhostname:7005/clusterjsp
  • Follow the instructions at the bottom of the displayed page.
  • To access the page from the other server in the client tier cluster change the the port number in the browser and hit enter. Notice the session attribute and value which you had added are not present because we have not yet enabled Coherence*Web.

Application Screenshot

Enable Coherence*Web Session Storage

  • Create a WLS deployment descriptor to enable Coherence*Web sessions by saving the text below into a new file called:
    <wls install…>/applications/clusterjsp-ear/clusterjsp-war/WEB-INF/weblogic.xml
&lt;?xml version="1.0"?&gt;

&lt;weblogic-web-app xmlns=""


  • In the Admin. Console navigate to the Deployments page.
  • Update the deployment by click the Select button next to the clusterjsp-ear application and click the Update button.
  • Repeat your previous test. This time you should see your Session attributes are present regardless of which client tier server you access.
  • Stop the servers one at a time in each tier and notice when the session data is no longer available.

For a multi-machine WebLogic  app-tier cluster, to ensure all machines have a common cookie path for the app, you must access the cluster jsp through a load balancer.

Sample using the test-only lb. which is shipped with coherence
i) Stat the lb. 
java -jar coherence-loadbalancer.jar
ii) Access via lb. url  and look for the “Executed From Server: sol11″ field in the response page.
iii) Kill this app-tier managed server instance.
iv) Reload the page from the lb. url.
v) Observe the “Executed From Server: sol12″ field has changed to the next available server in the lb. list.

Deployment 2 Large session sample-application

Next, deploy the sample-application.war (available from here) to just the ClientTier WebLogic Cluster.

The only step required to configure a web application to use Coherence*Web, select coherence-web as the persistence-store-type in WEB-INF/weblogic.xml as shown above. It’s that simple!

Next, run the application using the URL: http://your-ip-address:7005/sample-application and choose ‘Create Session’, then ‘Display Session’.  This is only a simple application with no real bells and whistles, to show you how to enable Coherence*Web for a web application.

You can see the output displays something similar to the following, which shows that Coherence is being used as the HTTP session store provider.

class: class weblogic.servlet.internal.session.CoherenceWebSessionData
sessionid: Vqi9nQtgCjpfO2F6FBHieVZV2vEmXfqF8Tyx6QDaQddqRhyKrFQM!502625314!1400916309965

The create.jsp file contains the following. Here we are just using the HTTP session and no Coherence specific code is used. You can experiment with the other links in the sample application.

&lt;%@ page import="java.util.*"%&gt;

session = request.getSession(true);

out.println("class: " + session.getClass() + "&lt;br/&gt;");
out.println("sessionid: " + session.getId());
HashMap m = new HashMap();
m.put("a", 1);
m.put("b", 1);
session.setAttribute("test", m);

Your web application is now using Coherence to store your HTTP sessions!

It’s very easy to scale out your HTTP session tier, just add another managed server to your StorageTier.

You can skip to the Conclusion below, or continue with the next section where I’ll show you how to install the Coherence JVisualVM Plug-in to view what’s going on under the covers.

Use the JVisualVM Plug-in from the Coherence Incubator Project to monitor the Coherence*Web session data

I’m using the Coherence JVisualVM Plug-in from the Coherence Incubator for viewing MBean information for the rest of this demo. You could just as well browse the MBean tree, but the Plug-in shows this in a nicer format.

For detailed information on how to install and connect jvisualVM to a WebLogic Server environment please see the Coherence Incubator site.

Install the Coherence VisualVM plugin brief steps

  • Download the latest pre-built plug-in module (NBM) from and save it to a local directory.
  • Start JVisualVM by running jvisualvm or jvisualvm.exe (for Windows) from the bin directory under your Java home.
  • Choose Tools -> Plugins.
  • Click on the ‘Downloads’ tab.
  • Click ‘Add Plugin’ and choose the file coherence-jvisualvm-12.2.0.nbm (from the location where you saved above).
  • Click ‘Install’ and follow the prompts to install.

Once installed, connect to either a remote or local JMX enabled Coherence cache server process using JMX

  • Restart jvisualvm with the following command (I have used UNIX style backslash for line continuation. If you are on Windows then please ensure the command is on one line.)
    $JAVA_HOME/bin/jvisualvm --cp:a \
    $WL_HOME/server/lib/wljmxclient.jar:$WL_HOME/server/lib/weblogic.jar \ \
  • To create a connection right-click on either ‘Local’ or ‘Remote’ under the ‘Applications’ tree. Use the following for the connection URI and enter the credentials for the WebLogic Server Admin: (the following should contain no spaces)
  • Once you have opened the newly created connection you will see the ‘Coherence Tab’.
  • For troubleshooting, see the Coherence Incubator site.

After connecting to the domain runtime mbean server, you should see the ‘Coherence’ tab displayed, select this tab and then the ‘Coherence*Web’ tab and you will see that there is a session that has been created.


If you then choose ‘Heavy Session’ in the sample web application, you will see the session overflow count go up as Coherence will store large attributes in a separate cache for optimised performance.

If you look at the ‘Caches’ tab, you will see the size of the session-storage and session-overflow caches are updated.

Coherence*Web Caches

Lastly, I used JMeter to create a load script that called the create.jsp and heavy.jsp to create sessions. You can see from the screenshot below, that you are able to view the number of sessions created and any session-reaping, which is cleaning up of old sessions.

More Sessions


It may have seemed that we went though a few steps above, but I wanted to show the evidence of the HTTP sessions begin stored Coherence*Web. The high-level steps to setup Coherence*Web are pretty straight forward:

  1. In your WebLogic domain, create a Coherence Cluster.
  2. Create a Client WebLogic Server Cluster and managed servers for your web apps and associate with the Coherence cluster as storage-disabled.
  3. Create a Storage WebLogic Server Cluster and managed servers for your data tier. Make this storage-enabled and also check ‘Coherence Web Local Storage Enabled‘.
  4. Update your WEB-INF/weblogic.xml to use coherence-web as persistence-store-type.
  5. Deploy your application and you are away.




This entry was posted in Examples and tagged , , . Bookmark the permalink.

13 Responses to Getting Started with Coherence*Web in WebLogic Server 12.1.2

  1. Pingback: WebLogic Partner Community Newsletter June 2014 | WebLogic Community

  2. Pingback: Getting Started with Coherence*Web in WebLogic Server 12.1.2 by Tim Middleton | WebLogic Community

  3. Shak says:

    Hello, thanks for the tutorial.
    I see you are accessing the application from http://yourhostname:7003/clusterjsp which is port # 7003. In the tutorial above, you never created any managed server on port 7003. Question is which instance is running on top of 7003? is it typo? if typo can you please let me know what is exact port(s) need to be used to see session replication between managed servers?

    • Thanks for your comment. The port should be 7005.
      We originally were going to have 2 client managed servers so 7003 and 7005 would have been the clients ports.
      Just changed to 7005 and we will update the tutorial next week.

  4. Shak says:

    Hi Tim, configured the domain with coherence and tested successfully with the help of tutorial in my local (2 managed servers, 2 storage servers)

    Being with above learning experience, I tried to build the same with following configuration. Basically all managed servers are spanned on different linux machines.

    After following the steps, session is not replicated across the appServers which are distributed in different machines. Are there any special settings that I need to follow if managed servers are spanned across multiple machines? please advice if you are aware of any specific settings.

    Following is summary of no of servers, cluster and sample ip and ports.

    servername/clustername/machineip/port/nodemanagerport ( two appclusters and 2 managed servers assigned to each cluster)

    appserver1 /appcluster01/
    appserver3 /appcluster01/

    appserver2 /appcluster02/
    appserver4 /appcluster02/

    StorageServers are as follows. (All storage servers targeted to single cluster)

    storageserver1 /storagecluster01/
    storageserver2 /storagecluster01/
    storageserver3 /storagecluster01/
    storageserver4 /storagecluster01/

    Assigned the app and storage cluster to default coherence cluster.
    Coherence clusters is just created and all values are default.

    I double checked the following entry exist in weblogic.xml


    Thanks much!

  5. Shak says:

    Hello, if you think my previous question is too big to read, the short question I’ve is, how to enable coherence for managed servers that run across multiple machines. Are there any settings that I’ve to follow either in weblogic.xml or in admin console? I tried to find documentation/tutorials for my case but could not find information.


    • Hi.
      Apologies, didn’t get back earlier, been on leave for a month.
      Check to see if you have the hostname in the listen address for the managed servers. If you leave them as default, then it will default to localhost, on each machine which will mean the Coherence clusters won’t connect across machines.

  6. Shak says:

    Thanks for your reply Tim!
    I double checked all managed servers and already respective host IPs exist in server configuration (checked config.xml too)

    To continue the trouble shooting, I’m searching the wl guides but no much information around high availability coherence web.
    I tried with different settings in coherence as follows.

    Clustering mode –> Changed to multi cast. Looks like all servers are joining the cluster but deployment is failing with following message (not pasting entire trace) .

    are there any settings I need to look into Well Known Address part in coherence ?


    • Have a look in the log files for any Coherence related errors/ messages. In particular “localhost”. When you start the second managed server on the different machine, you should see a message in the logs saying the member has joined.

  7. Amazing and straightforward tutorial; just a quick question … We can say that this configuration is an out-of-process coherence approach ? Thanks …

  8. Thanks for this post. It helped me to get started in Coherence as I was preparing myself for the “Oracle WebLogic Server 12c: Advanced Administrator II” cert test. I’ve referenced your post in the study guide I wrote for this test:

  9. Rupal Chawla says:

    Great article, loved it. Thanks!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s