1 Reply Latest reply on Aug 20, 2008 5:57 AM by fmarchioni fmarchioni

    Stateful Session replication not working......

    fmarchioni fmarchioni Newbie

      Hello,
      I'm trying a basic Cluster SFSB which autoincrements a fields....

      @Stateful
      @Clustered
      public class HelloBean implements HelloBeanItf,Serializable {
      int counter = 0;
      public void doSomething() {
       counter++;
       System.out.println("Value of counter is " + counter);
      
      }


      The code is recalled by a JSP

      <%!
      HelloBeanItf ejb = null;
      
      public void jspInit () {
      try {
      
      
      InitialContext ctx = new InitialContext();
      
      ejb = (HelloBeanItf) ctx.lookup("cluster/HelloBean/local");
      }
      catch (Exception exc) { exc.printStackTrace();
      }
      }
      
      
      %>
      
      <%
      ejb.doSomething();
       %>
      

      Unfortunately when I invoke the JSP the session seems not to replicate...in other words I can see the server is load balancing the calls between nodes but the value stays the same when moves from one node to the other

      Node 1: 11:03:42,859 INFO [STDOUT] Value of counter is 11
      Node 2: 11:03:42,859 INFO [STDOUT] Value of counter is 11
      Node 1: 11:03:42,859 INFO [STDOUT] Value of counter is 12
      Node 2: 11:03:42,859 INFO [STDOUT] Value of counter is 12


      The cluster works fine on the HTTP side (I have seen the HTTP session gets replicated) so the problem is only on SFSB.

      Do I need any additional configuration besides the @Clustered notation ?
      I'm using JBoss 4.2.0 version.
      Thanks a lot
      Francis


        • 1. Re: Stateful Session replication not working......
          fmarchioni fmarchioni Newbie

          well storing the EJB handle in the Http session solves the problem.....so each instance of Tomcat was keeping an handle of the EJB that's way it didn't work.

          Anyway is it possible to configure the cluster so that when a request reaches the HTTP Server it stays ON THE SAME SERVER and keeps a backup of the Session on the other Node ?
          I have tried playing with the sticky session attribute but nothing happened

          worker.loadbalancer.sticky_session=1

          Any additional configuration file may help ?