Score:2

Where are Tomcat 9 sessions stored in Ubuntu 18?

ph flag

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?

Score:1
by flag

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).

Gustavo avatar
ph flag
I couldn't find any sessions there. Is it possible they are only in memory?
Piotr P. Karwasz avatar
by flag
While the application is running they are kept in memory. To write them to disk stop the application (e.g. stop the server).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.