The below exception, java.lang.IllegalStateExceptio actually thrown by the Session Manager if the session object is INVALID.
Stack Trace: java.lang.IllegalStateException: Session Object Internals: id : B5z1QYCq0E9vRvMhAz1Ghqg hashCode : 1067073434 create time : Tue Jan 17 09:12:59 GMT 2012 last access : Tue Jan 17 09:13:48 GMT 2012 max inactive interval : 1200 user name : anonymous valid session : false new session : false overflowed : false app name : CDWeb non-serializable app specific session data : null serializable app specific session data : [] at com.ibm.ws.webcontainer.httpsession.SessionData.getValueGuts(SessionData.java:856) at com.ibm.ws.webcontainer.httpsession.SessionData.getValue(SessionData.java:1262) at com.ibm.ws.webcontainer.httpsession.SessionData.getAttribute(SessionData.java:1148) at com.ibm.ws.webcontainer.httpsession.HttpSessionFacade.getAttribute(HttpSessionFacade.java:120) at org.apache.myfaces.context.servlet.SessionMap.getAttribute(SessionMap.java:47) at org.apache.myfaces.context.servlet.AbstractAttributeMap.put(AbstractAttributeMap.java:107) at com.sun.facelets.FaceletViewHandler.getResponseEncoding(FaceletViewHandler.java:426) at com.sun.facelets.FaceletViewHandler.createResponseWriter(FaceletViewHandler.java:391)
From where do we get IllegalStateException
SessionData.putValue
SessionData.getValue
SessionData.removeValue
SessionData.isNew
SessionData.getMaxInactiveInterval
Solution to Illegal State Exception
SessionData.putValue
SessionData.getValue
SessionData.removeValue
SessionData.isNew
SessionData.getMaxInactiveInterval
Solution to Illegal State Exception
Basically there are two main reasons this exception:
- When application invalidates the session and then tries to access it in the same request.
- When two java threads within the JVM both gets access to the session object and One thread invalidates the session and then the other one thread attempts to use the session object
For example, Check the below code
HttpSession cdSession = request.getSession();
The cdSession.invalidate() method is called.
One of the following methods is called on the session object:
cdSession.putValue("codedairyTxtString", "is the session invalid");
cdSession.getValue(codedairyTxtString);
cdSession.removeValue(codedairyTxtString);
cdSession .isNew();
Any other attempted operation on the session object.
Check your servlet or JSP file that threw the exception to determine if the scenario described above applies to your situation and take necessary action.
This happens when two threads within the JVM gain access to the session object and
When one thread invalidates the session and then the other thread attempts to use the session object.
For example
Let’s say our code in Thread1 gains access to the session object by calling
HttpSession exSession= request.getSession();
And Our Code in Thread2 could gains access to the same session object by calling:
HttpSession exSession= request.getSession();
Let’s say Thread2 invalidates the session object and then if Thread1 attempts to use the session object by calling one of the following methods:
mySession.putValue(codedairyTxtString, "is the session invalid");
mySession.getValue(codedairyTxtString);
mySession.removeValue(codedairyTxtString);
mySession.isNew();
Related posts:

It looks like the code is misnisg from your comment above.If you are not able to post it, you can sent that to me at rukumar at adobe dot com