Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Tracking down invalidated session

I'm trying to track down a weird error relating to sessions. Using Jetty 8.1.8, I'm getting an IllegalStateException when I try to use getAttribute() to get an attribute from a session, which apparently indicates that the session has been invalidated.

When a session is created, I store a reference to it in an ArrayList, so that I can display a list of logged-in users with code like this:

  HttpSession session = sessionList.get(n);
  SessionState s = (SessionState)session.getAttribute("state");
  ...                                    ^^^^^^^^^^^^ IllegalStateException!

and I have a session listener which removes sessions from the list when they are destroyed:

  public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    sessionList.remove(session);
    ...
  }

This is hard for me to figure out since it happened on a live system and I can't reproduce it elsewhere, and I can't get at the sessionList on the live system. It just happened the other day for the first time following an update a couple of weeks ago, so there's obviously something in the updated code which has caused it, but working through the changelogs I can't see anything remotely relevant -- this is all old code.

It looks like the session is being invalidated without sessionDestroyed() being called -- is there any way that could happen? Or is there any other reason for an IllegalStateException to be thrown?

TIA,
--
John English


Back to the top