2

我们的应用程序堆栈是在 tomcat 7 中运行的 hibernate/spring/spring security/JSF。

我已经下载并安装了开源 Terracotta 3.6.2。

我们要配置 Terracotta DSO。我们正在使用 spring security SessionRegistryImpl.java 来获取登录用户的会话信息,但是这个类是不可序列化的,因此我们的会话变得不可序列化。

遵循以下文档

http://terracotta.org/documentation/web-sessions/installation-guide http://terracotta.org/documentation/terracotta-dso/dso-install http://docs.terracotta.org/confluence/display/docs/配置+指南+和+参考

我们的应用程序中有以下罐子

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

我有以下 TIM

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

我不断收到org.springframework.security.core.session.SessionRegistryImpl 的 java.io.NotSerializableException

在这种情况下是否可以使用 Terracotta DSO 配置集群?

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>
4

0 回答 0