0

I'm trying to implement tomcat embedded web server. Everything working good. But session is cleared when I restart.

I'm trying to implement correct session persistence configuration. But no success. This is my current code snippet. What is wrong with it?

        ...
        var store = new FileStore();
        store.setDirectory("/tmp/tomcat.embedded.session.store.demo");

        var manager = new PersistentManager();
        manager.setStore(store);
        manager.setSaveOnRestart(true);

        var context = tomcat.addWebapp("", docBase);
        context.setReloadable(false);
        context.setSessionTimeout(60);
        context.setManager(manager);
        ...

Edit:

I found that StandardManager can store sessions to file calling method StandardManager.unload(). But StandardManager.load() no effect on sessions.

I step ahead but still no success.

hurelhuyag
  • 1,691
  • 1
  • 15
  • 20

1 Answers1

0

Store the session in db or redis (redis should not be on the same server)

Umair Anwar
  • 522
  • 1
  • 4
  • 15
  • Yes this is on the future plan. But currenlty I need drop in replacement for tomcat9 package installed by ubuntu's apt-get package manager. – hurelhuyag Jun 19 '20 at 09:35