tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Champlin <>
Subject Concurrency Issue With a SessionListener.
Date Tue, 03 May 2005 21:29:53 GMT
I am having issues with a SessionListener I have written. The purpose of 
the Listener is to maintain a List of Active Users on the site. Here is 
the code for the Listener.


public class ActiveUsersListener implements Serializable, 
HttpSessionListener {

public static Set activeSessions = new HashSet();

public void sessionCreated(HttpSessionEvent event) {

public void sessionDestroyed(HttpSessionEvent event) {

public static List getActiveUsers() {
 List users = new ArrayList();
 Iterator sessionIter = activeSessions.iterator();
 HttpSession session = null;
 EmoUser user = null;
 while (sessionIter.hasNext()) {
   session = (HttpSession);
   user = (EmoUser) session.getAttribute(EmoUser.SESSION_KEY);
   if (user != null & user.hasLoggedIn()) {
 return users;



I then have a webpage that calls ActiveUsersListener.getActiveUsers() to 
list out all the active users on the site. Note: I don't just store the 
User objects because the user object doesn't get created until the user 
logs in.

So the problem I am having is that this code works fine on a single box 
under Tomcat 5.5.4 . However, as soon as we go into a cluster we get 
lockups in Tomcat. The server is completely unresponsive, and there are 
no log/error messages.

Because of this I am assuming we have a concurrency issue, however I 
have no idea where the problem is.

A few more bits of information, we persist sessions to file system on 
shut down, and we use in memory session replication only when 
session.setAttribute() is called (DirtyFlag).

Thank you in advance for any help.

Jacob Champlin
EMO Corporation

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

View raw message