Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Clustering with Jetty and WADI

What is WADI?

WADI is an acronym of 'WADI Application Distribution Infrastructure'. WADI started life as a solution to the problems surrounding the distribution of state in clustered web tiers, but is becoming a more generalised distributed space service.

How to cluster your web application with Jetty and WADI

First, svn checkout jetty and then buid it by calling mvn install. Once it finishes, go to jetty.home/extras/wadi and mvn install that project. Besides compiling the java files and generating the jetty-wadi-session-manager jar file, this will copy all the dependencies into jetty.home/lib/wadi.

To cluster a webapp, you need to define the WadiSessionManager and create an instance of WadiSessionHandler (passing the WadiSessionManager object as a constructor parameter). Then set the WadiSessionHandler as your webapp's SessionHandler. You can do this in a context xml config file.

Code Block
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/wadi</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
  <Set name="extractWAR">false</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>

  <Set name="SessionHandler">
    <New class="org.mortbay.jetty.servlet.wadi.WadiSessionHandler">
	<New id="wadiSessionManager" class="org.mortbay.jetty.servlet.wadi.WadiSessionManager">
	  <Arg><SystemProperty name="" default="red"/></Arg>
	  <Arg type="int">2</Arg>
	  <Arg>http://localhost:<SystemProperty name="jetty.port" default="8080"/>/test</Arg>
	  <Arg type="int">24</Arg>
	  <Arg type="int">360</Arg>


This context xml config file is readily usable. After building the jetty.home/extras/wadi project, drop this config file into the jetty.home/contexts directory.  You can create a node in the cluster by calling "java -Djetty.port=portnumber -jar start.jar etc/jetty.xml" in the jetty home directory (where nodename=a distinct node name for this node, and portnumber=a distinct port number for this node).

For instance, if you want to create a cluster with three nodes, you can do so by calling the following: 

java -Djetty.port=7070 -jar start.jar etc/jetty-wadi-cluster.xml

java -Djetty.port=8080 -jar start.jar etc/jetty-wadi-cluster.xml

java -Djetty.port=9090 -jar start.jar etc/jetty-wadi-cluster.xml 

Contact the core Jetty developers at
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery