Apache Tomcat - phax/phoss-smp GitHub Wiki
Make sure you set the attribute encodedSolidusHandling to true in your server.xml
<Connector
...
encodedSolidusHandling="decode" />Apache Tomcat must be set up with the following java system property:
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH = true
It's also important that if you deploy as a WAR file, that "unpack WARs" is enabled (which it is by default).
This can be done by adding:
-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH="true"
as a JVM argument (Tomcat Properties -> Java -> Java Options) or
put it into the catalina.sh in Linux:
CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"or catalina.bat on Windows:
set CATALINA_OPTS=%CATALINA_OPTS% -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=trueSince v8.0.12 the SQL version of phoss SMP by default creates a table tomcat_sessions which can be used to store session information there.
See #424 for the original ticket.
The following configuration is hopefully (!) working for Tomcat 10. I didn't test it.
Update your app's META-INF/context.xml (or server.xml globally):
NOTE: You must set either the org.apache.catalina.session.StandardSession.ACTIVITY_CHECK or org.apache.catalina.STRICT_SERVLET_COMPLIANCE system properties to true for the persistent manager to work correctly.
<Manager className="org.apache.catalina.session.PersistentManager"
maxIdleSwap="3600"
maxIdleBackup="10800"
saveOnRestart="true"
processExpiresFrequency="6">
<Store className="org.apache.catalina.session.DataSourceStore"
dataSourceName="jdbc/sessionsDB"
localDataSource="true"
sessionTable="tomcat_sessions"
sessionAppCol="app_name"
sessionDataCol="session_data"
sessionIdCol="session_id"
sessionLastAccessedCol="last_access"
sessionMaxInactiveCol="max_inactive"
sessionValidCol="valid_session" />
</Manager>Please note that the column names for the table must be provided as stated in the above example!
Add this Resource in the same context.xml (or server.xml globally):
<Resource name="jdbc/sessionsDB"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="10000"
username="smp"
password="smp"
driverClassName="com.mysql.cj.jdbc.Driver"
_url="jdbc:mysql://localhost:3306/smp?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true"
url="jdbc:mysql://host.docker.internal:3306/smp?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true"
/>The example configuration for Tomcat 9 and MySQL may look like this:
<Manager className="org.apache.catalina.session.PersistentManager"
saveOnRestart="true">
<Store className="org.apache.catalina.session.JDBCStore"
connectionURL="jdbc:mysql://<MYSQL_HOST>:<PORT>/<DATABASE>"
driverName="com.mysql.cj.jdbc.Driver"
connectionName="<DB_USER>"
connectionPassword="<DB_PASSWORD>"
sessionTable="tomcat_sessions"
sessionIdCol="session_id"
sessionValidCol="valid_session"
sessionMaxInactiveCol="max_inactive"
sessionLastAccessedCol="last_access"
sessionDataCol="session_data"/>
</Manager>Please note that the column names for the table must be provided as stated in the above example!