I am new to terracotta. We just installed 3.5.2 Web Sessions to cluster sessions under Tomcat 6.0.29. We have a Grails 3.6 app running on CentOS 5.4.
Everything is working great except when we get an error response. Whenever we get an error response such as 404 Not Found the user gets kicked back out to the login screen.
After investigation we noticed that when these errors happen the request header has the terracotta jsessionid such as JSESSIONID=9l7zYXF9UCkDesL7VttH.20 but the response header has the Tomcat style jsessionid such as JSESSIONID=7A69191B82AF7139662D2E2CA419A750.
We are using Shiro 1.1.3 for authentication if that helps.
We found a solution to this problem though we still don't understand it. We were putting the terracotta valve in the tomcat server's conf/context.xml. I then tried all scenarios where we:
a) put the valve in our .war in /META-INF/context.xml. That didnt' work.
b) put the valve in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default. That didn't work.
c) put the valve in the $CATALINA_HOME/conf/[enginename]/[hostname]/<contextname>.xml. That didn't work.
d) put the valve in the Host section of the conf/server.xml. THAT WORKED!!
I suspect that by putting the valve in the server.xml it was loading before any standard tomcat session manager which fixed this issue.
I am using Terracotta 3.7.7 for my Tomcat 7 session clustering, and also using Spring Security Oauth2 version 1.0.5.RELEASE.
Every time when my application server redirected my browser to the OAuth2 authorization server for the authorization code, the jsessionid cookie in my browser was set to Tomcat style jsessionid. So when the authorization server redirected my browser to my application server, my application server regarded the Tomcat session as anonymous, as my application server only authenticated my old Terracotta session before.
The TerracottaTomcat70xSessionValve valve used to be put under conf/Catalina/localhost/myApp.xml.
Now as you suggested, I moved the valve to conf/server.xml, and there is no more Tomcat style session. Everything works.