8 Replies Latest reply on Aug 18, 2010 6:47 PM by krajwade.kaddy121.yahoo.com

    Clustering Seam 2.1.2 and Jboss AS 5.1

    ventmonkey

      Hi all.  I am trying to get multi server clustering set up with Jboss AS 5.1 and Seam 2.1.2.  In my web.xml I have
      <distributable/>
      and in components.xml I have



      <core:init distributable="true"/>
      <security:identity authenticate-method="#{authBean.login}" remember-me="true"/>





      in AuthBean I have



          @In(create = true)
          private Identity identity;
          @In(required = false)
          @Out(scope = ScopeType.SESSION, required = false)
          public Account userSessionAccount;
      
          public Boolean login() {
                  Account account = (Account) em.createQuery(
                      "SELECT a FROM Account a WHERE LOWER(a.userName) = :userName AND a.password = :password").
                      setParameter("userName", identity.getUsername().toLowerCase()).
                      setParameter("password", identity.getPassword()).getSingleResult();
      
                  setUserSessionAccount((Account) account.clone());
              return true;
          }





      I'm starting Jboss AS with



      sh run.sh -c all -b 10.1.1.1 -Djboss.messaging.ServerPeerID=1 -u 239.255.100.100




      and 10.1.1.2 on the other server.  Both servers see eachother



      [org.jboss.cache.RPCManagerImpl] (Incoming-16,10.1.1.1:50118) Received new cluster view: [10.1.1.1:50118|1] [10.1.1.1:50118, 10.1.1.2:36343]




      but when I visit my application from a web browser on one of the servers, nothing seems to happen in the JbossAS log file on the other server. 


      As per the seam reference, to confirm that the HTTP session is replicating I should bring up the jmx-console and look for Category: jboss.cache : Entry: service:TomcatClusteringCache, but no such service is listed. 


      What I'm really looking for is to have the login, and Account userSessionAccount replicated on both servers.


      I am fairly clueless when it comes to JbossAS and Seam clustering, so any help would be greatly appreciated.


      Thanks all!
      Mason





        • 1. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
          asookazian

          are you using mod_jk for load balancing (round robin), sticky sessions and failover?  JBoss has mod_cluster which is an improved mod_jk.  I wrote this clustering setup doc for JBoss 4.2.x and Windows: http://community.jboss.org/message/215073#215073.  HTH.

          • 2. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
            ventmonkey

            I am currently using modjk.  I will gladly switch to modcluster.


            I guess I'm more trying to figure out how to cluster the application, so that signing onto one node will sign the user onto other nodes. Is that possible?

            • 3. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
              asookazian

              You are outjecting a session-scoped Account instance which presumably is authentication related.  Make sure session replication is turned on in your cluster config.  I believe JBoss replicates session-state in HttpSession after each public interface method call (although I believe this is configurable as well, read the JBoss docs on this).  In case of failover for a node, then your Account should already be available in the backup JBoss node for that session (seamless failover). 


              http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Clustering_Guide/clustering-http-state.html



              In Section 1.5.3, 'Configure worker nodes in mod_jk', we covered how to use sticky sessions to make sure that a client in a session always hits the same server node in order to maintain the session state. However, that is not an ideal solution. The load might be unevenly distributed over the nodes over time and if a node goes down, all its session data is lost. A better and more reliable solution is to replicate session data across all nodes in the cluster. This way, the client can hit any server node and obtain the same session states.
              • 4. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
                ventmonkey

                Thanks for your help with this Arbi.


                According to the Jboss AS 5.1 documentation, as per my understand of it anyway, all I need to do to enable http session replication is to add <distributable/> to my web.xml...which I have done.  According to Seam I need to add <core:init distributable="true"/> to components.xml.


                Account is a persistence entity, and it is serializable.  I am Outjecting an instance of that as userSessionAccount when the user authenticates. 


                I'm probably missing something simple...I just can't seem to figure out what.

                • 5. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
                  ventmonkey

                  I also tried enabling



                  <Valve className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn"/>




                  and that didnt seem to help.


                  I'm now just running the Seam Booking example...and that doesnt seem to work either.  If I log in on one server, and switch to the other server, I will not be authenticated.

                  • 6. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
                    kapitanpetko

                    How do you switch to the other server? You need to access Apache, login, check the logs to see which server you accessed (or the session cookie), kill that server's JBoss, then try to access some page requiring authentication. If you are not prompted for login, it worked. If you do, there is something wrong with your setup. For failover to work you need to do some setup at both nodes as well (set node names, etc.), do check the docs once again.


                    • 7. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
                      ventmonkey

                      Yup...I'm a moron.  I had miss configured Mod JK (Taken a node out for testing, and forgot to put it back in).  This is now working perfectly.  Thanks all for your help!

                      • 8. Re: Clustering Seam 2.1.2 and Jboss AS 5.1
                        krajwade.kaddy121.yahoo.com

                        Hi Mason,


                        I am testing seam's booking example with Jboss 5.1 for clustering and session failover. I am facing the same problem as you mention in this thread. Can you please share the steps that you followed to make it working? Do we have to use Mod JK. I was not able to find the instruction for configuring Mod JK while working with seam examples.


                        Also, were you able to find Category: jboss.cache : Entry: service:TomcatClusteringCache in jmx-console ?