Oracle Coherence

I was trying to setup Oracle Coherence on my Ubuntu machine. I searched for some good examples online but no luck. So i decided to post my own. Here is my experience setting up Oracle Coherence on a linux distro.

1. Download Coherence
You can download the latest Oracle Coherence from their website. At the time of this writing the current version is 3.7 (

I have JAVA_HOME already setup. If not you would need to set that up first.
After that you would need to set up the following:

$ export COHERENCE_HOME=/home/YOU_LOCATION/coherence

Note: You can put this on your .profile if you want to plan to preserve your variables, else you will have to export the variable on each terminal tabs.

3. Basic setup
Since I am trying this out on 1 machine, I will do a basic setup. For this, I will have a cache server and a cache factory process running. Coherence by default does multicast to find cluster members. It could be set up to be unicast, if you so choose. Learn more from the pdf link below in the notes section. (You can simply ignore the details for now)

4. Touch up the scripts
The coherence directory should have few scripts inside the ‘bin’ folder. I was getting “Bad substitution” error when I tried running the script out of the box, So, I decided to trim it down. Below is the condensed version of the script that made sense to me and cut out some fat.
One of the thing to point out is that I added “-Dtangosol.coherence.cluster=shrestha -Dtangosol.coherence.clusterport=8090” in the JAVA_OPTS which doesnt exist in the canned script

See the scripts below:

# specify the JVM heap size

if [ -f $JAVA_HOME/bin/java ]; then

if [[ $1 == '-jmx' ]]; then

JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY $JMXPROPERTIES -Dtangosol.coherence.cluster=shrestha -Dtangosol.coherence.clusterport=8090"

$JAVAEXEC -server -showversion $JAVA_OPTS -cp $COHERENCE_HOME/lib/coherence.jar $1

if [ -f $JAVA_HOME/bin/java ]; then

if [ $STORAGE_ENABLED == "true" ]; then
	echo "** Starting storage enabled console **"
	echo "** Starting storage disabled console **"

JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.coherence.distributed.localstorage=$STORAGE_ENABLED $JMXPROPERTIES -Dtangosol.coherence.cluster=shrestha -Dtangosol.coherence.clusterport=8090"

$JAVAEXEC -server -showversion $JAVA_OPTS -cp $COHERENCE_HOME/lib/coherence.jar $1

5. Running Coherence
If you got through here, you are ready to start your coherence.
Now, Lets start the server, simply run the “”

$ ./

You should see something like

... ... ...
  ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.7.1, OldestMemberId=1}
  InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
  PartitionedCache{Name=DistributedCache, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
  ReplicatedCache{Name=ReplicatedCache, State=(SERVICE_STARTED), Id=3, Version=3.0, OldestMemberId=1}
  Optimistic{Name=OptimisticCache, State=(SERVICE_STARTED), Id=4, Version=3.0, OldestMemberId=1}
  InvocationService{Name=InvocationService, State=(SERVICE_STARTED), Id=5, Version=3.1, OldestMemberId=1}

Started DefaultCacheServer...

Now, lets start a

$ ./

if everything went right, you may see a shell “Map(?) :”

... ... ...

2011-10-18 23:14:10.951/2.581 Oracle Coherence GE <D5> (thread=Invocation:Management, member=2): Service Management joined the cluster with senior service member 1

Map (?):

foo bar
Now its time to take it for a spin,
in the pompt type “cache Test” to create cache named “Test”

Map (?): cache Test
Map (Test):

Lets add a key value pair, for this, we do “foo” “bar”

Map Test): put foo bar

Verify the value is stored property

Map (Test): get foo

If you want to try more, you can spin up another “coherence” process by running the “” in another terminal. You can work with same cache, you can add values in that and go back to previous shell and see the value is globally replicated.


2 thoughts on “Oracle Coherence

  1. Thanks Manij for this very simple & helpful material.
    Could you please refer anything similar for a multi-node coherence cluster set up.

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 )

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