4 Replies Latest reply on May 6, 2013 10:45 AM by seacuke23

    EJB call hangs client

    seacuke23 Newbie

      I'm trying to test out a simple clustered setup.  I'm using 7.1.3 and the canned standalone-ha config file.  I start two nodes as follows:

       

      standalone.bat -Djboss.server.base.dir=C:\training\jboss\jboss-as-7.1.3.Final\clust1 -Djboss.node.name=clust1 -Djboss.server.name=clust1 -Djboss.default.multicast.address=230.0.0.41 -c=standalone-ha.xml
      
      standalone.bat -Djboss.server.base.dir=C:\training\jboss\jboss-as-7.1.3.Final\clust2 -Djboss.default.multicast.address=230.0.0.41 -Djboss.node.name=clust2 -Djboss.server.name=clust2 -Djboss.socket.binding.port-offset=100 -c=standalone-ha.xml
      

       

      I have the following basic EJB:

       

      package com.me.test.ejb;
      
      public interface MyInterface {
                public int foo(int a, int b);
      }
      

       

       

      package com.me.test.ejb;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import org.jboss.ejb3.annotation.Clustered;
      
      @Stateless
      @Remote(MyInterface.class)
      @Clustered
      public class MyBean implements MyInterface {
                @Override
                public int foo(int a, int b) {
                          System.out.println("Foo called with " + a + ", " + b);
                          return a*b;
                }
      }
      

       

      I'm using the following as my client:

       

      package com.me.test.client;
      
      import java.util.Random;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import com.me.test.ejb.MyInterface;
      
      public class BeanTestClient {
                public static void main(String[] args) {
                          Random r = new Random();
                          try {
                                    InitialContext ic = new InitialContext();
                                    MyInterface intf = (MyInterface) ic.lookup("ejb:/MyBeanTester//MyBean!com.me.test.ejb.MyInterface");
                                    while (true) {
                                              int a = r.nextInt() % 100;
                                              int b = r.nextInt() % 100;
                                              System.out.println(a + " X " + b + " = " + intf.foo(a, b));
                                              Thread.sleep(1000);
                                    }
                          }
                          catch (NamingException e) {
                                    e.printStackTrace();
                          }
                          catch (InterruptedException e) {
                                    e.printStackTrace();
                          }
                }
      }
      

       

      jndi.properties:

       

      java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
      jboss.naming.client.ejb.context=true
      

       

      jboss-ejb-client.properties

       

      endpoint.name=client-endpoint
      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
      
      remote.clusters=ejb
      remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.cluster.ejb.clusternode.selector=org.jboss.ejb.client.RandomClusterNodeSelector
      remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
      
      remote.connections=node1,node2
      
      remote.connection.node1.host=127.0.0.1
      remote.connection.node1.port = 4447
      remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.connection.node1.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
      remote.connection.node1.username=appuser
      remote.connection.node1.password=appuserpass
      
      remote.connection.node2.host=127.0.0.1
      remote.connection.node2.port = 4547
      remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.connection.node2.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
      remote.connection.node2.username=appuser
      remote.connection.node2.password=appuserpass
      

       

      When I start the app servers they appear to start up fine.  I deploy the jar by putting it in both deployment directories and it seems to deploy fine.  When I run the client it hangs after it outputs the following:

       

      Looking it up
      Apr 30, 2013 2:58:02 PM org.jboss.ejb.client.EJBClient <clinit>
      INFO: JBoss EJB Client version 1.0.11.Final
      Making the call
      Apr 30, 2013 2:58:02 PM org.xnio.Xnio <clinit>
      INFO: XNIO Version 3.0.6.GA
      Apr 30, 2013 2:58:02 PM org.xnio.nio.NioXnio <clinit>
      INFO: XNIO NIO Implementation Version 3.0.6.GA
      Apr 30, 2013 2:58:02 PM org.jboss.remoting3.EndpointImpl <clinit>
      INFO: JBoss Remoting version 3.2.8.SP1
      Apr 30, 2013 2:58:03 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
      INFO: EJBCLIENT000017: Received server version 1 and marshalling strategies [river]
      Apr 30, 2013 2:58:03 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
      INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@476e06e6, receiver=Remoting connection EJB receiver [connection=Remoting connection <439cf2df>,channel=jboss.ejb,nodename=clust1]} on channel Channel ID e7a7dc99 (outbound) of Remoting connection 13b3d473 to /127.0.0.1:4447
      

       

      This is where it appears to sit and never come back:

       

      Capture.PNG

       

      If I kill the client I see this in the logs for the nodes:

       

      14:59:13,471 ERROR [org.jboss.remoting.remote.connection] (Remoting "clust1" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
      14:59:13,483 ERROR [org.jboss.remoting.remote.connection] (Remoting "clust1" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
      

       

      14:59:13,472 ERROR [org.jboss.remoting.remote.connection] (Remoting "clust2" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
      14:59:13,482 ERROR [org.jboss.remoting.remote.connection] (Remoting "clust2" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
      

       

      Then if I start the client again it processes as expected.  It seems to work every time after the first time...calls being processed on both nodes...killing one results in processing on the other only...bringing it back up and it starts processing again.  If I start the application servers with the jar in the deployments directory it seems to exhibit the same behaviour.

       

      I've noticed that if I remove the @Clustered annotation it doesn't have the same problem.  However, if I do that I noticed that if I kill one of the nodes and bring it back up it doesn't process there anymore.

       

      SO...I'm prone to thinking there's a bug in the AS somewhere.  Usually when I think that though it turns out I'm doing something stupid.  I'm not totally confident about my jboss-ejb-client.properties..so maybe I've got something wrong in there? Seems to have some redundancies in it at least that may not be necessary.  I haven't seen any similar issues being tracked.  Can you have a look at what I have here and give me your thoughts?