4 Replies Latest reply on Mar 7, 2006 3:35 AM by luong duy

    stateless session bean fail over and HA-RMI fail over not wo

    luong duy Newbie

      dear all, i have 2 jboss 4.03Ssp1 be configed as cluster. And one stateless session bean with load balance and fail over enable. But it seem to be not work. Stateless bean also deployed in 2 server

      this is my ejb-jab.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <display-name>ServerBean</display-name>
      <enterprise-beans>

      <ejb-name>ejbName</ejb-name>
      com.gcs.rmw.server.ServerHome
      com.gcs.rmw.server.Server
      <local-home>com.gcs.rmw.server.ServerBeanLocalHome</local-home>
      com.gcs.rmw.server.ServerBeanLocal
      <ejb-class>com.gcs.rmw.server.ServerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>
      True
      <cluster-config>
      <partition-name>MyPartition</partition-name>
      <home-load-balance-policy>
      org.jboss.ha.framework.interfaces.FirstAvailable
      </home-load-balance-policy>
      <bean-load-balance-policy>
      org.jboss.ha.framework.interfaces.FirstAvailable
      </bean-load-balance-policy>
      </cluster-config>


      </enterprise-beans>
      <ejb-client-jar>ServerClient</ejb-client-jar>
      </ejb-jar>

      i wrote some code to test this fearture.

      System.out.println("loop ....");
      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.factory.url.pkgs", "jboss.naming:org.jnp.interfaces");
      props.setProperty("jnp.partitionName", SysUtil.getPartitionName());
      props.setProperty("java.naming.provider.url", "localhost:1100,duytest:1100");
      props.setProperty("jnp.discoveryTimeout", "10000");

      InitialContext ctx = new InitialContext(props);
      Object renoteObj = ctx.lookup("ServerBean");
      ServerHome home = (ServerHome)renoteObj;
      server = home.create();

      while(true){
      try{

      server.userLogin("admin", "admin");
      System.out.println(renoteObj.toString());
      System.gc();
      }catch(Exception e){
      //continue run
      System.out.println(e.getMessage());
      }

      }

      when in while loop only jboss 1 recieve call , and jboss 2 do not recieve call. I try again with another load balance policy but nothing change. When i turn off jboss 1, i recieve error tell that "Service unavalable"

        • 1. Re: stateless session bean fail over and HA-RMI fail over no
          Brian Stansberry Master

          Did you add

          <clustered>true</clustered>


          to jboss.xml?

          • 2. Re: stateless session bean fail over and HA-RMI fail over no
            luong duy Newbie

            thank you for your reply. In my jboss.xml have

            <clustered>True</clustered>


            but same proplem still occur. And recieve exception in client code as :

            Error unmarshaling return header; nested exception is:
             java.net.SocketException: Connection reset
            Connection refused to host: 172.16.10.66; nested exception is:
             java.net.ConnectException: Connection refused: connect


            I used HA-RMI. but it have same problem with stateless cluster. I have 2 HA_RMI server with names is : MyService, MySession. After that i used 2 HA_RMI server to create 2 HA-RMI stub

            create HA-RMI "MyService" and HA-RMI stub. After that bound this stub to HA-JNDI

            Properties p = new Properties();
            
            p.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
            
            p.setProperty("java.naming.factory.url.pkgs","jboss.naming:org.jnp.interfaces");
            
            p.setProperty("java.naming.provider.url", SysUtil.getClusterServerList());
            
            p.setProperty("jnp.partitionName", SysUtil.getPartitionName());
            
            p.setProperty("jnp.discoveryTimeout", "10000");
            
            InitialContext ctx = new InitialContext(p);
            
            Object obj1 = ctx.lookup((newStringBuilder("/HAPartition/")).append(SysUtil.getPartitionName()).toString());
            
            HAPartition myPartition = (HAPartition)obj1;
            
            RMWServer myService = new RMWServerImpl();
            
            HARMIServerImpl rmiserver = new HARMIServerImpl(myPartition, "MyService", RMWServer.class, myService);
            
            RMWServer stub = (RMWServer)rmiserver.createHAStub(newRoundRobin());
            
            ctx.rebind("RMI_STUB", stub);
            


            client will get this stub which is created above in HA-JNDI and call function in it. That function is :

            RMWSession obj = new RMWSessionImpl(server, user);
            
            Properties p = new Properties();
            
            p.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
            
            p.setProperty("java.naming.factory.url.pkgs","jboss.naming:org.jnp.interfaces");
            
            p.setProperty("java.naming.provider.url", SysUtil.getClusterServerList());
            
            p.setProperty("jnp.partitionName", SysUtil.getPartitionName());
            
            p.setProperty("jnp.discoveryTimeout", "10000");
            
            InitialContext ctx = new InitialContext(p);
            
            HAPartition myPartition = (HAPartition)ctx.lookup((new StringBuilder("/HAPartition/")).append(SysUtil.getPartitionName()).toString());
            
            HARMIServerImpl rmiserver = new HARMIServerImpl(myPartition, "MySession", RMWSession.class, obj);
            
            return (RMWSession)rmiserver.createHAStub(new RoundRobin());
            


            and client will use second stub to do some jobs. And balance and fail over not happen

            • 3. Re: stateless session bean fail over and HA-RMI fail over no
              Brian Stansberry Master

              I notice above that you have your cluster-config stuff in ejb-jar.xml, not in jboss.xml.

              • 4. Re: stateless session bean fail over and HA-RMI fail over no
                luong duy Newbie

                it's my mistake but i corrected it. But it seem not work until i change standardjboss.xml, in stateless-rmi-invoker config it as same as clustered-stateless-rmi-invoker. fail-over and loadbalance in stateless ejb work well. But not in case of rmi. It seem to be smart stub of ha rmi can not update list alive jboss. it only can get list alive server one and never update this list. So when add 1 jboss to current partition. smart stub don't know that have one new server in cluster partition