Terracotta DSO with spring security THROWS NotSerializableException for SessionRegistryImpl.java

787 Views Asked by At

Our application stack is hibernate/ spring / spring security/JSF running inside tomcat 7.

I have downloaded and installed the Open source Terracotta 3.6.2.

We want to configure Terracotta DSO. we are using spring security SessionRegistryImpl.java to get session information on logged in users, but this class is not serializable and thus our session becomes unserializable.

Followed the following documentations

http://terracotta.org/documentation/web-sessions/installation-guide http://terracotta.org/documentation/terracotta-dso/dso-install http://docs.terracotta.org/confluence/display/docs/Configuration+Guide+and+Reference

We have the following jars in our application

 <dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core</artifactId>
    <version>2.5.2</version>
 </dependency>
 <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>terracotta-toolkit-1.5-runtime</artifactId>
      <version>4.2.0</version>
 </dependency>
 <dependency>
    <groupId>org.terracotta.session</groupId>
    <artifactId>terracotta-session</artifactId>
    <version>1.2.2</version>
 </dependency>

I have the following TIM

<module name="tim-tomcat-7.0"/>
 <module name="tim-spring-security-2.0" />
 <module name="tim-ehcache-1.7" />

I am constantly getting java.io.NotSerializableException for org.springframework.security.core.session.SessionRegistryImpl

Is it possible to do configure cluster with Terracotta DSO in this case?

tc-config.xml

<?xml version="1.0" encoding="UTF-8"?> 
<tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-5.xsd"
xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <servers>
        <server host="localhost" name="localhost:9510" bind="0.0.0.0"> 
            <dso-port bind="10.7.65.31">9510</dso-port> 
            <jmx-port bind="10.7.65.31">9520</jmx-port>
            <data>C:/Terracotta/terracotta/server-data</data>
            <logs>C:/Terracotta/terracotta/server-logs</logs>
            <index>C:/Terracotta/terracotta/server-index</index>
            <statistics>C:/Terracotta/terracotta/server-statistics</statistics>
            <dso>
                <client-reconnect-window>120</client-reconnect-window>
                <persistence>
                  <mode>temporary-swap-only</mode>
                  <offheap>
                    <enabled>false</enabled>
                    <maxDataSize>5g</maxDataSize>
                  </offheap>
                </persistence>
            </dso>
        </server>
    </servers>

    <clients>
        <logs>C:/Terracotta/terracotta/client-logs/</logs>
        <modules>
            <module name="tim-tomcat-7.0"/>
            <module name="tim-spring-security-2.0" />
            <module name="tim-ehcache-1.7" />           

        </modules>

        <dso>
            <debugging>
                <instrumentation-logging>
                  <class>true</class>
                  <locks>false</locks>
                  <transient-root>true</transient-root>
                  <roots>true</roots>
                  <distributed-methods>false</distributed-methods>
                </instrumentation-logging>

                <runtime-logging>
                  <non-portable-dump>true</non-portable-dump>
                  <lock-debug>true</lock-debug>
                  <wait-notify-debug>false</wait-notify-debug>
                  <distributed-method-debug>false</distributed-method-debug>
                  <new-object-debug>true</new-object-debug>
                  <named-loader-debug>false</named-loader-debug>
                </runtime-logging>

                <runtime-output-options>
                  <auto-lock-details>true</auto-lock-details>
                  <caller>true</caller>
                  <full-stack>false</full-stack>
                </runtime-output-options>

            </debugging>
        </dso>
    </clients>

    <application>
      <dso>
        <instrumented-classes>
            <include>
               <class-expression>org.springframework.*</class-expression>
                <honor-transient>true</honor-transient>
             </include>
             <include>
               <class-expression>org.springframework..*</class-expression>
                <honor-transient>true</honor-transient>
             </include>
             <include>
               <class-expression>org.springframework...*</class-expression>
                <honor-transient>true</honor-transient>
             </include>

        </instrumented-classes>

        <roots>
            <root>
              <field-name>org.springframework.security.core.session.SessionRegistryImpl.principals</field-name>
              <root-name>PRINCIPALS</root-name>
            </root>
            <root>
              <field-name>org.springframework.security.core.session.SessionRegistryImpl.sessionIds</field-name>
              <root-name>SESSIONIDS</root-name>
            </root>
        </roots>


        <locks>

          <autolock auto-synchronized="true">
            <method-expression>* org.springframework.security.core.session.SessionRegistryImpl.re*(..)</method-expression>
          </autolock>   
        </locks>

            <injected-instances>
             <injected-field>
               <field-name>org.springframework.security.core.session.SessionRegistryImpl.principals</field-name>
             </injected-field>
             <injected-field>
               <field-name>org.springframework.security.core.session.SessionRegistryImpl.sessionIds</field-name>
             </injected-field>
            </injected-instances>

        <web-applications>
            <web-application serialization="false">nymphaea</web-application>
        </web-applications>
        <dso-reflection-enabled>false</dso-reflection-enabled>

      </dso>
    </application>


</tc:tc-config>

ehcache.xml

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd"
         updateCheck="true" monitoring="autodetect"
         dynamicConfig="true">


    <diskStore path="java.io.tmpdir"/>

    <defaultCache
        maxElementsInMemory="50000"
        eternal="false"
        timeToIdleSeconds="900"
        timeToLiveSeconds="1200"
        >
        <terracotta clustered="true" valueMode="identity"/>

        </defaultCache>


    <cache name="ContentHierarchyNode"
        maxElementsInMemory="500000"
        eternal="false"
        timeToIdleSeconds="900"
        timeToLiveSeconds="21600"        
        />

</ehcache>
0

There are 0 best solutions below