If you do not wish to communicate over webservices, the alternative is to connect up your space with terracotta.

There are many was to do this, depending on how you designed your application. The way that is chosen here, is to use a webapp container - simply because the lookup application is designed as a webapp.


You need Terracotta with the the jetty TIM module. This has been explained in the installation chapter.


For your convenience, a bundled version of jetty has been created. You could, of course, choose a different app server. But these instructions are for jetty.

If you like to set up your own jetty server and instance, you find instructions here: Clustering Web Applications.

Unpacking jetty application

For your convenience, a bundled jetty application has been created in semispace-google-app. Unpack the zip file and run the preliminary installation script:

mkdir somewhere
cd somewhere
unzip <wereever>/google-app.zip
cd bin
chmod a+x afterInstallation.sh

Notice that you get informed to set some environment variables. These are needed for Jetty to run. The bundled Jetty script is the same script that follows the standard distribution, with the addition of Terracotta specific variables, as explained below.

If you do not add the Terracotta variables, the Jetty instance runs as a standalone server.

Environment variables

You need the following environment variables for connecting to the Terracotta server:

export TC_INSTALL_DIR=<path_to_local_Terracotta_home>
export TC_CONFIG_PATH="localhost:9510"

These variables are needed for all instances that shall communicate over Terracotta.

Distributing jetty instances

You need to have unzipped the google-app.zip in two different directories, lets call them A and B. You also need to have started the Terracotta server, as explained in Terracotta configuration chapter.


export TC_INSTALL_DIR=<where terracotta is installed>
${TC_INSTALL_DIR}/bin/start-tc-server.sh -f some/path/to/config/tc-config.xml 

Starting up the first jetty instance

It is presumed that you already have configured the paths as applicable to your environment, i.e. exported the variables that are printed after running afterInstallation.sh and exporting TC_INSTALL_DIR and TC_CONFIG_PATH.

Run in the jetty bin directory:

./jetty.sh start

You should see something similar to:

Using Terracotta
Starting BootJarTool...
2009-06-23 13:09:30,165 INFO - Terracotta 3.2.0, as of ....

Starting up the second jetty instance

Unzip google-app.zip into a different directory. You need to use a different port as we are running the service on the same machine. If you use two different machines, this, naturally, does not apply. (However, your configuration references would need to be tailored to support this.)

Change the jetty port in etc/jetty.xml from

<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>


<Set name="port"><SystemProperty name="jetty.port" default="8081"/></Set>

Testing the application:

Open two browser windows: http://localhost:8080/semispace-google/index.html and http://localhost:8081/semispace-google/index.html

This represents your two servers A and B, and should present the same entry page.

Submit a new user in one of the windows. You see the user list is updated with the user. Now, press the index button in the other window. You shall see the same user in that window.

Using the client

You can use the client application over webservices on either servers. The respective endpoints would be: http://localhost:8080/semispace-google/services/tokenspace and http://localhost:8081/semispace-google/services/tokenspace


./gclient.sh http://localhost:8080/semispace-google/services/tokenspace

Integrating directly from the client

Direct integration from the client is as of Terracotta version 3.x not possible. The problem is that the client does not use spring for setting up the SemiSpace connection, whereas the webapp does, and this does not mix well.

Stopping the server

In the Jetty bin directory do:

./jetty.sh stop