14 Replies Latest reply on Jan 16, 2003 8:46 AM by Rohan Talip

    Patch for Sticky Sessions + Failover

    integ Newbie

      Hi,
      I think there is a bug in ClusterManager.findSession() during session failover when using sticky sessions - the responseThreadLocal.get() returns a null.
      I have done a workaround for this, with this patch sticky session failover works fine & if you bring up the other server, new requests will stick there fine too.
      For people who do not want to compile the source file, just replace tomcat4-service.jar with the one i have attached. This is for Jboss-3.0.3_tomcat-4.0.5.
      Please review if its all right for you & let me know if anything is broken.
      How do i submit this patch in sourceforge, do i just upload the source file under 'Patches'?
      Thanks
      Rakesh

        • 1. Re: Patch for Sticky Sessions + Failover
          Thomas Peuss Newbie

          Hello!

          > I think there is a bug in
          > ClusterManager.findSession() during session failover
          > when using sticky sessions - the
          > responseThreadLocal.get() returns a null.
          > I have done a workaround for this, with this patch
          > sticky session failover works fine & if you bring up
          > the other server, new requests will stick there fine
          > too.
          > For people who do not want to compile the source
          > file, just replace tomcat4-service.jar with the one i
          > have attached. This is for Jboss-3.0.3_tomcat-4.0.5.
          > Please review if its all right for you & let me know
          > if anything is broken.

          I will have a look at your patch...

          CU
          Thomas

          • 2. Re: Patch for Sticky Sessions + Failover
            Thomas Peuss Newbie

            Your patch looks nice. But can you please attach a version where you mark the parts of the file you changed?

            Thanks
            Thomas

            • 3. Re: Patch for Sticky Sessions + Failover
              Jake Fear Newbie

              After looking this over I don't see anything that looks like it would not work with tomcat 4.1.12, has anyone tried this already? Intend to try it myself anyway, but if anyone else already has some experiences to share that would be great.

              Jake

              • 4. Re: Patch for Sticky Sessions + Failover
                Chris Fesler Newbie

                integ's ClusterManager.java works great in JBoss 3.0.4 with Tomcat 4.1.12. Sticky sessions (tested with mod_jk2 under Apache 1.3), failover and failback work great. Nice work, integ!

                Attached is the tomcat41-service.jar for the described configuration.

                • 5. Re: Patch for Sticky Sessions + Failover
                  Chris Fesler Newbie

                  [NOTE: This is my second attempt at posting; apparently I'm a little inept when it comes to actually *using* web applications. Anyway, please forgive any duplicate post by me on this subject]

                  I am pleased to report that the new ClusterManager provided by integ works great on JBoss 3.0.4 with Tomcat 4.1.12. Sticky sessions (tested with Apache 1.3 and mod_jk2), failover and failback all work as expected (thanks, integ!).

                  I'll attach the tomcat41-service.jar that I built with the new ClusterManager, should anyone want to avoid the trouble of building it themselves.

                  Chris

                  • 6. Re: Patch for Sticky Sessions + Failover
                    Thomas Peuss Newbie

                    I incorporated your fix in catalina and tomcat41 in branches 3.0, 3.2 and HEAD...

                    Thanks for your fine work!

                    Thomas

                    • 7. Re: Patch for Sticky Sessions + Failover
                      Senthil Nathan M Newbie

                      I am facing problems with sticky session when using Jetty with Apache using mod_jk2 connector. The problem is that if I include the tag in the web.xml sticky sessions are not functioning properly. Apache (mod_jk) forwards the HTTP requests randomly to any available jetty/jboss servers. Whether this patch will solve my problem? Pls help me.

                      • 8. Re: Patch for Sticky Sessions + Failover
                        Thomas Peuss Newbie

                        This thread is about sticky session and clustering with TOMCAT!

                        CU
                        Thomas

                        • 9. Re: Patch for Sticky Sessions + Failover
                          Dennis Cartier Newbie

                          I know this is a bit off topic, but how did you get the tomcat41 portion to build from the sources? I pulled down the 3.2 branch (with the fix), but I cannot get the tomcat stuff to build. The readme file in the catalina directory does not seem to work for tomcat4.1.12. when I create the local.properties and point it to the LE version of tomcat4.1.12 I installed, it gives 63 errors and warnings.

                          Can anyone give me a clue as to how to do this?

                          • 10. Re: Patch for Sticky Sessions + Failover
                            Dennis Cartier Newbie

                            Oops. I can be pretty much sure that I will figure something out, right after posting a message asking how to do it :)

                            I should have been using the tomcat41 directory, not catalina. I also had to edit the module.version file to point it to 3.2.0RC1 rather than 3.2.0beta2

                            Seems to have built what looks like a complete bundle.

                            Dennis

                            • 11. Re: Patch for Sticky Sessions + Failover
                              Rohan Talip Newbie

                              Hi,

                              I believe that I have managed to get HTTP session clustering to work (it seems to work most of the time) using:
                              a) jboss-3.0.4_tomcat-4.1.12
                              b) the tomcat41-service.jar posted here
                              c) using the "all" configuration
                              d) an Ajp13Connector in tomcat41-service.xml
                              e) Apache 1.3 + mod_jk-1.3.eapi.so from http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.1/bin/linux/i386/ (although there is a 1.2.2 version of jk which I have not tried yet).

                              Strangely enough I did not need to specify a jvmRoute attribute to the Engine tag in tomcat41-service.xml for the sessions to be sticky (at least with my minimal testing).
                              (I had a simple JSP that printed to System.out and showed up in the console log.)

                              Can anyone explain if the jvmRoute attribute is necessary? And if so, why?

                              I am also seeing these errors:

                              17:42:55,999 INFO [MainDeployer] Starting deployment of package: file:/usr/local/jboss-3.0.4_tomcat-4.1.12/server/all/deploy/jbossweb-ejb.jar
                              17:42:56,202 ERROR [EJBDeployer] Verfiy failed
                              java.lang.NoClassDefFoundError: org/mortbay/j2ee/session/interfaces/CMPStateHome

                              Is this related to Jetty (which I have not installed or configured) ?

                              Can someone please tell me how I can fix this? Can I disable something? Or do I need to install something, e.g. Jetty?

                              Thanks,

                              Rohan

                              • 12. Re: Patch for Sticky Sessions + Failover
                                integ Newbie

                                Sorry for not posting back earlier...
                                Thanks for reviewing the patch - Glad to know it works.
                                Rohan, the error seems related to Jetty.

                                • 13. Re: Patch for Sticky Sessions + Failover
                                  Jay Scannell Newbie

                                  I tried using your tomcat4-service.jar and it failed. I am running jboss-3.0.5RC1_tomcat-4.1.18 (tested with Apache 1.3.26 and mod_jk/1.2.1. My application works fine until I bring the second server online and then I lose the session continuously, I am asked to login repeatedly.

                                  Any ideas?

                                  • 14. Re: Patch for Sticky Sessions + Failover
                                    Rohan Talip Newbie

                                    If you are using Tomcat 4.1.x you most likely need the tomcat41-service.jar posted here in the same thread and not the tomcat4-service.jar (note the difference in versions).