Tomcat Persistence on Session Restart

Looking for a bit of insight on getting Tomcat to pick up our sessions on server restart for better client UX. Have j2ee/jee sessionManagement set up. All values stored in session are strings or numbers, no complex object, so serializable.

App.cfc settings include:

  this.name                    = "MyAppName";
  this.sessionStorage          = "memory";
  this.sessionManagement       = true;
  this.sessiontype             = "j2ee"; // tried jee here, same result
  this.sessionCluster = true;

Have added <Manager> to context.xml (either StandardManager or PersistentManager works). Running Tomcat as a Windows service, but looking for advice so that this works on our linux servers as well.

The SESSIONS.ser file is created (StandardManager) or individual session files are created (PersistentManager with FileStore). The files are consumed by Tomcat on restart. There are no deserialization error in Tomcat logs (nor in console when running Tomcat stop/start scripts). The client still has the same JSessionID and urltoken on restart. But the custom values added to Session are not present on restart (number: user_id and string: test).

Thanks for any help :slight_smile:

OS: Windows10
Java Version: Java 21
Tomcat Version: 9.0.108
Lucee Version: 6.2.2.91

If your running older releases and hit a problem, check the change log or try the latest release / snapshot to see if the problem is solved.

Use the session management with Lucee via cache providers or database for persistence.

Session management has a lot of love since 6.2.2 was released

https://download.lucee.org/changelog/?version=6.2

Thanks! I’ll have a look at cache providers again, and Lucee version upgrading.

We had used DB for sessions and experienced serious slowdown issues, as opposed to the snappy feel of sessions stored in memory.

Sessioncluster=true means sessions are loaded and saved for every single request

1 Like

We use a valkey cache, and it’s excellent. I recommend it.