tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From János Löbb <>
Subject [Cluster] context question
Date Mon, 11 Apr 2011 16:45:57 GMT

/Tomcat 7.0.10, OSX 10.6.5, jk 1.2.31, and httpd 2.2.17/

 Without any explicit parameters in server.xml, just by setting the jvmRoute attribute in
the Engine element and enabling Clustering, session failover worked if I shut down one or
the other tomcat instance or the one httpd that was not the reverse proxy.  

However when I just stopped the example webapp in one tomcat, the session did not failover
and I received a 404 http error instead of the expected session page from the other tomcat.

Based upon the instructions found in the book:


You'll also need to add distributed="true" to the webapp's <Context> element. If there
is no <Context> element declared for it anywhere, you will need to create one. You can
create one by making a newCATALINA_HOME/conf/[EngineName]/[HostName]/examples.xml context
XML fragment file or by adding one to server.xml.

my thought was that the ReplicatedContect was not initiated.  Well, I already learned that
I should not add any context into server.xml and there is nothing in the

bml0066:local administrator$ ls -l tomcat1/conf/Catalina/localhost/
bml0066:local administrator$ 

directory,  so I created a META-INF directory inside the examples directory and placed a context.xml
there with the following content:

bml0066:local administrator$ cat tomcat1/webapps/examples/META-INF/context.xml 
<?xml version="1.0" encoding="UTF-8"?>
<Context className="org.apache.catalina.ha.context.ReplicatedContext" distributed="true"

I did it on both tomcats and bounced them.  Now when I look the log, I see the following warning
just after restart:

INFO: Deploying web application directory examples
Apr 11, 2011 12:00:28 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'distributed' to 'true' did
not find a matching property.
Apr 11, 2011 12:00:28 PM org.apache.catalina.tribes.tipis.AbstractReplicatedMap init
INFO: Initializing AbstractReplicatedMap with context name:/examples
Apr 11, 2011 12:00:28 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Apr 11, 2011 12:00:28 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()

So the first question is, should I use the distributed="true" property here ?  Is the book
right ?  I think it is from 2007.  I already have the <distributable/> tag in the webapp's

The second question is what to do to avoid the 404 message and fail the session over instead
of it, when I just stop the webapp on the tomcat instance?  By default I am using sticky sessions.

bml0066:local administrator$ cat apache2/conf/ 
worker.list = lb,jkstatus,tomcat3
#,tomcat2,tomcat4 = True = False


worker.tomcat1.type = ajp13 =
worker.tomcat1.port = 8109
worker.tomcat1.lbfactor = 1

#worker.tomcat2.type = ajp13 =
#worker.tomcat2.port = 8209
#worker.tomcat2.lbfactor = 1

worker.tomcat3.type = ajp13 =
worker.tomcat3.port = 8309
worker.tomcat3.lbfactor = 1

#worker.tomcat4.type = ajp13 =
#worker.tomcat4.port = 8409
#worker.tomcat4.lbfactor = 1


Thanks ahead,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message