Steve Gom
Steve Gom

Reputation: 75

How can I change Session Persistence in Tomcat 7.X?

I am using Tomcat 7.0 and I found a reference of how to change session savings into the database. But I don't get how to change org.apache.catalina.session.StandardSession.ACTIVITY_CHECK to true

The link that I am referencing is http://www.intelligrape.com/blog/2010/07/21/tomcat-6-session-persistence-through-jdbcstore/

I am using localhost Tomcat 7.X downloaded as zip, MySQL 5.5, STS 3.1(Incuding Eclipse)

Any figuring out?

Upvotes: 0

Views: 2954

Answers (2)

Nishant Gupta
Nishant Gupta

Reputation: 1

add below line in catalina.bat just after where you found other JAVA OPTS already being set. set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"

e.g.

rem Register custom URL handlers

rem Do this here so custom URL handles (specifically 'war:...') can be used in the security policy

set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"

set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"

Upvotes: 0

toomasr
toomasr

Reputation: 4781

This is a system property ( http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html ) so to set these you have to specify the -D option. In your case "-Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true".

But where? Well, System Properties are given to the Java process when it starts. In case of Tomcat you can use a environment variable called $JAVA_OPTS which is given to the Java process on startup. So

export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"

and then run Tomcat. For this to persist make sure that the user running catalina.sh has this environment variable always set.

Upvotes: 2

Related Questions