wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Tomcat randomly invalidating sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat randomly invalidating sessions" Watch "Tomcat randomly invalidating sessions" New topic
Author

Tomcat randomly invalidating sessions

Bryan Perino
Greenhorn

Joined: May 16, 2014
Posts: 5
Hello All,

I am having some trouble with my tomcat application. It randomly removes sessions and forces the user to log back in again. This only happens when the app is run with other applications on the same server. If I run it with a fresh Tomcat install with nothing else, it seems to run fine. I am using Tomcat 7.0.42 with JVM 1.7.0_07-b11 and on Windows Server 2008 R2. Any help is much appreciated.

I cross posted this on Stack Overflow.
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Are all your root paths the same ? ie. Are all your application's files under one parent directory ?

This symptom can be caused by the browser not sending the session cookie when it has to load two different context root paths for different files ( .htm under one context and .jpeg under another context path ).


This is especially poignant since it works well with only the app loaded and nothing else.
Bryan Perino
Greenhorn

Joined: May 16, 2014
Posts: 5
Each application is under a different path. I created a HttpSessionListener that is never triggered. This application only has 2 jsp files. The front end is done in AngularJS, so I don't know if there is a way to trigger session generation with that. The backend is Hibernate and Spring. I did notice a cookie mistmatch when the error happens



Edit:

There is however a lot of cross path communication between my app, which has two paths.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Does the Tomcat manager show that the context has been deployed as a single web app?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryan Perino
Greenhorn

Joined: May 16, 2014
Posts: 5
I believe that the app is a single context, /rdk. However, it talks to RDKServer which is a separate one.



/rdk is the AngularJS app which talks to the RDKServer which handles all the data transactions and doesn't have any session associates with it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

So all of your session woes are within the /rdk context?
Bryan Perino
Greenhorn

Joined: May 16, 2014
Posts: 5
I actually think that I solved it. The issue had to do with persisting the sessions on disk. For some strange reason, it wasn't working and kept killing them. I had to change the following in context.xml from this



to this



Everything seems fine now. Thank you for the help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Thanks for posting back with your findings!
 
jQuery in Action, 2nd edition
 
subject: Tomcat randomly invalidating sessions