java.lang.IllegalStateException thrown by the Session Manager
 Technote (troubleshooting)
 
Problem(Abstract)
The exception, java.lang.IllegalStateException, is thrown by the Session Manager if the session object is invalid.
 
Cause
The following methods will all throw the IllegalStateException if the session object is invalid:
  • SessionData.putValue
  • SessionData.getValue
  • SessionData.removeValue
  • SessionData.isNew
  • SessionData.getMaxInactiveInterval

The following is an IllegalStateException:

[02.11.15 04:05:54:500 PST] 3ced77c6 ServletInstan X Uncaught service() exception root cause {0}: {1}  
"LoginServlet"
java.lang.IllegalStateException:
         
Session Object Internals:
id : QJP45EI1FEA0XAOKNVSDENA
hashCode : 1681586149
create time : Fri Nov 15 04:04:03 PST 2002
last access : Fri Nov 15 04:05:26 PST 2002
max inactive interval : 3600
user name : anonymous
valid session : false
new session : false
session active : false
overflowed : false
session application parameters :
enable epm : true
non-serializable app specific session data: {loginData=com.bb.toys.bobject.Data@9bf4f7e6}
serializable app specific session data : {previousPage=login}
session data list : Session Data List ->  id : MRU next : null prev : null
at com.ibm.servlet.personalization.sessiontracking.SessionData.putValue
at com.ibm.servlet.personalization.sessiontracking.SessionData.setAttribute
at com.bb.toys.servlet.LoginServlet.doPost(LoginServlet.java
at javax.servlet.http.HttpServlet.service
 
Resolving the problem
There are two reasons this exception occurs:
  1. The application invalidates the session and then tries to access it on the same request.

  2. Two threads within the JVM™ both gain access to the session object. One thread invalidates the session and then the other thread attempts to use the session object

The following steps occur within the same request:
  1. HttpSession mySession = request.getSession();

  2. The mySession.invalidate() method is called.

  3. One of the following methods is called on the session object:
    1. mySession.putValue(myString, "is the session invalid");
    2. mySession.getValue(myString);
    3. mySession.removeValue(myString);
    4. mySession.isNew();
    5. Any other attempted operation on the session object.

Check the servlet or JavaServer™ Pages (JSP™) that threw the exception to determine if the scenario described above applies to your situation. If not, continue to the next section.

Two threads within the JVM both gain access to the session object. One thread invalidates the session and then the other thread attempts to use the session object.

1. Application code in Thread-1 gains access to the session object by calling:

HttpSession mySession = request.getSession();

2. Application code in Thread-1 gains access to the session object by calling:

HttpSession mySession = request.getSession();

3. Application code in Thread-2 gains access to the same session object by calling:

HttpSession mySession = request.getSession();

4. Thread-2 invalidates the session object.


5. Thread-1 attempts to use the session object by calling one of the following methods:
  1. mySession.putValue(myString, "is the session invalid");
  2. mySession.getValue(myString);
  3. mySession.removeValue(myString);
  4. mySession.isNew();
  5. Any other attempted operation on the session object.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Sessions and Session Management
Operating system(s): Windows
Software version: 5.1
Software edition:
Reference #: 1082806
IBM Group: Software Group
Modified date: Mar 31, 2006