Where are Tomcat 9 sessions stored in Ubuntu 18?
The manual below says:
Apache Tomcat 9 Configuration Reference - The Manager Component
Introduction
A Manager element MAY be nested inside a Context component. If it is not included, a default Manager configuration will be created automatically
My Context has no nested Manager element:
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
</Context>
So, the default is to be used:
The Manager Component - Standard Manager Implementation
pathname
: Absolute or relative (to the work directory for this Context) pathname of the file in which session state will be preserved across application restarts, if possible. The default is "SESSIONS.ser".
The question is, where can I find this SESSIONS.ser
file?
Solution 1:
If you don't configure a session manager explicitly, one is provided for you. If the attribute pathname
is a relative location, it is resolved against the application's working directory, which is by default:
$CATALINA_BASE/work/[enginename]/[hostname]/[appname]
(usually $CATALINA_BASE/work/Catalina/localhost/[appname]
).
Following symbolic links on Ubuntu it is situated in:
/var/cache/tomcat9/[enginename]/[hostname]/[appname]
You can change the location of the working directory setting the workDir
parameter of <Host>
(c.f. documentation).