IBM Support

java.lang.IllegalStateException thrown by the Session Manager

Troubleshooting


Problem

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.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java Message Service (JMS)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.0;7.0;6.1;6.0","Edition":"Advanced;Base;Network Deployment;Single Server","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21082806