• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.IllegalStateException: invalidate: Session already invalidated

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am getting following error:


I am opening two sessions at a time

but before this newSession I already have opened session as following:

this session is closed at the end when all tasks are done that throws the aforementioned stackTrace. I stuck that using newSession.invlidate() why session instance is also invalidating?

Thanks in anticipation
 
Dhaval J. Patel
Ranch Hand
Posts: 90
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
req.getSession(true) does not create a new session. It will create a new session only if there is no existing session. So in your case when you do req.getSession(true) it will return a reference to the same session you had before. If you invalidate that session and then try to do stuff with the same session, it wont work. It might be a different reference to the session, but still it is pointing the session that was just invalidated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic