Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stale session after tomcat restart

 
Ankur Sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I see this weird behavior in my application.
Scenario:
App runs in Tomcat (Env: Java, Struts, iBATIS, Eclipse ) in my machine locally
I login to application. browse few pages.
I restart the Tomcat.

now if I continue browsing my application it just works fine. it does not ask me to login again. It happens sporadically.

Has any body else came across this issue?

Please let me know if you know why it happens and how to resolve this issue.

Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It happens because Tomcat is allowed to serialize sessions out to the hard disk and pick them back up on restart. This is considered desirable behavior if you want to prevent it you will have to do some programming.

Bill
 
Ankur Sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks William.
Is there any way to tell tomcat not to do so?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like "persistent" sessions are on by default and can be configured in the context.xml configuration file. I suspect that this configuration depends on which version of tomcat you have. In my Tomcat 5.5.20 default context.xml file I find the following;


I have not played with it - let us know what happens

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic