Mark Thomas wrote:

Without looking at your source code, no idea. I have just checked the Tomcat
source and every attribute that implements HttpSessionActivationListener will have sessionWillPassivate() and
sessionDidActivate() called.

I've got a simple class that keeps track of the sessions that are active. See sourcecode below. As you can see, sessions are being added or removed from a set if sessionCreated/sessionDestroyed is called (this part is working).


I also want to add all sessions activated at Tomcat startup. This is what sessionDidActive() is implemented for.

But neither sessionDidActive() nor sessionWillPassivate() is called. Is there any important information missing?

My web.xml includes:

<listener>
<listener-class>mypackage.UserSessions</listener-class>
</listener>

Regards,

Andreas


public class UserSessions implements HttpSessionListener, HttpSessionActivationListener
{
private static final Set sessions = new HashSet();

public void sessionCreated(HttpSessionEvent sessionEvent)
{
HttpSession session = sessionEvent.getSession();

synchronized(sessions)
{
sessions.add(session);
}
}


        public void sessionDestroyed(HttpSessionEvent sessionEvent)
        {
                HttpSession session = sessionEvent.getSession();

                synchronized(sessions)
                {
                        sessions.remove(session);
                }
        }

        public void sessionDidActivate(HttpSessionEvent sessionEvent)
        {
                System.out.println("sessionDidActivate() called");

                HttpSession session = sessionEvent.getSession();
                
                synchronized(sessions)
                {
                        sessions.add(session);
                }
        }

        public void sessionWillPassivate(HttpSessionEvent arg0)
        {
                System.out.println("sessionWillPassivate() called");
        }
}


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to