In my nginx I have set upstream and setup sticky session with:
upstream tomcat {
      ip_hash;
      server localhost:XXXX;
      server localhost:XXXY;
      server localhost:XXYY;
}
I have added <distributable/> tag in my web.xml (in all tomcats)
Have added this in my tomcat/conf/server.xml file:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="6">
          <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="5000"
                      selectorTimeout="100"
                      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"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
          </Channel>
          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=".*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt"/>
          <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                    tempDir="/tmp/war-temp/"
                    deployDir="/tmp/war-deploy/"
                    watchDir="/tmp/war-listen/"
                    watchEnabled="false"/>
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>
Have added this in my tomcat/conf/context.xml:
<Manager className="org.apache.catalina.ha.session.BackupManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"
                   mapSendOptions="6"/>
But now I am able to login to my application. What happens is if all 3 or any 2 instances are started and I login, I see the JSESSIONID e..g xyz234.tomcat1
Now if I turn off tomcat1, it will take me back to login page since tomcat1 is shutdown. I login again and it creates session with say tomcat2, meanwhile, I turn tomcat1 up again, my application will take me back to login page. So, I face two problems:
- I want to stay login even either of my tomcat (holding session) goes down.
 - And if that tomcat comes up again, I should still stay up.
 
Note: I am using JSF2 app, so not sure if it has anything to do with it.