tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mindaugas Zaksauskas <>
Subject Clustered Tomcat & JSF
Date Thu, 20 Oct 2005 08:33:23 GMT

I was trying to make this work for more than a week, maybe there will be 
someone who will be able to help.

Configuration: Tomcat 5.0.28@Debian GNU/Linux, 2.6.13. Cluster configured 
accordingly to (Apache2 + mod_jk + two 
Tomcat instances on the same box, memory-in-memory session replication). 
Sticky sessions are turned off, so by requesting a page, I am redirected to 
Tomcat #1, then to Tomcat #2, then again to Tomcat #1 and so on.

At the beginning, the application I was trying to launch was developed and 
tested on a regular (non-clustered) Tomcat, and the life was beautiful :) 
When we decided to move to the cluster, we got some exceptions about 
non-serializable data in the session which we had all fixed.

The actual problem is that session data in our application doesn't seem to be 
replicated under random circumstances and under random screens. What I see 
from the logs, that entire managed beans are missing from within different 
Tomcat instance and they really exist in another.

I have written a simple .jsp test with the session replication and it seemed 
to work well.

Then I got really angry and tried with more sophisticated example which didn't 
(see sourcecode at the bottom). This example puts relatively large amount of 
data into the session and under next request this data is retrieved from the 
different Tomcat node. I have tested this with IE 6.0 - by opening this page, 
and clicking on F5 (refresh), the upper number (current timestamp) must go to 
the bottom at the next request. The bug scenario is the following: hold F5 
for a couple of seconds and wait till hundreds of refreshes/session 
replications finish. Then, quickly save the upper number and _immediately_ 
click F5 once again. The upper number is *not* getting written into the 
session nor gets replicated, some old value is retrieved from the session 
instead. Sometimes, the following exception appears in the catalina.out.

The two problems (session replication in my test and in JSF webapp) might have 
nothing in common just because I have tested JSF webapp under no load. 
However, our JSF webapp is supposed to handle 200+ users so this also might 
be an issue.

I have tried the same config on Tomcat 5.5.9. I have tried all the replication 
modes (pooled, synchronous and asynchronous), also tried with 
waitForAck=false. None has helped.

I'd appreciate any help. Thanks in advance.


8<-------------------------- test.jsp ------------------------------------

<!-- Tomcat id is accordingly to instance, for another I have "Tomcat 1" -->
<h1>Tomcat 2</h1>

<%= request.getSession().getId() %><BR>
    String[] mas = new String[10000];
    long time = System.currentTimeMillis() % 100000;
    out.println("time: " + time + "<BR>");
    for (int i=0; i<mas.length; i++)
        mas[i] = "" + time;

    String[] from_session = (String[]) session.getAttribute("attr");
    if (from_session == null)
        session.setAttribute("attr", mas);
        out.println("from session: null");
        String value = from_session[0].toString();
        out.println("got from session; length:" + from_session.length + "  
value: " + value);
        session.setAttribute("attr", mas);
8<-------------------------- test.jsp ------------------------------------

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message