两台server放置在同一个局域网中,每台server上面部署一样的web application现使用tomcat6.0自带的session复制功能实现session共享,但现在的问题是:两个tomcat之间session却共享不了下面是server.xml文件中的配置
...
<Engine name="Catalina" defaultHost="localhost">      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="8">          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4"
                        port="45564"
                        frequency="500"
                        dropTime="3000"/>
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      maxThreads="6"/>            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
          </Channel>          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
      </Cluster>      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->      </Host>
    </Engine>
...

解决方案 »

  1.   

    楼主还是好好查下tomcat官方文档吧,很有用的
      

  2.   

    即使配置为最简单的模式也不可以实现session的复制,现在很纠结中希望大虾指点一二<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" />
      

  3.   

    两台Tomcat是否使用的是相同的域名访问?如果你使用IP分别访问的话当然会重新生成一个新的Session。
    Cookie中的SessionID没法提交。
      

  4.   

    两台Tomcat没有使用域名,就是使用的IP地址访问不知还有没有别的方案没???急等啊
      

  5.   

    没有出错日志,系统是部署在linux平台上
      

  6.   

    直接使用IP那当然不会提交了,两个IP浏览器当然当作两个域名。
    你看看在两台服务器前加个LVS之类的,然后用LVS的IP来访问就可以了。
      

  7.   

    要用集群的话,干脆按通用的做法来,对外用apache服务,负载均衡的服务只对apache服务开放就可以了。看看官网的配置吧,很有帮助的。