title: Clustered EJBs not being balanced in JBoss AS 7
body: <p>I've successfully setup a cluster of 2 JBoss AS 7 instances, and deployed the following SLSB: </p>
  
  <pre><code>@Stateless
  @Remote(TestEJBRemote.class)
  @Clustered
  public class TestEJB implements TestEJBRemote {
    private static final long serialVersionUID = 1L;
    private static final Logger logger = Logger.getLogger(...);
  
    @Override
    public void test() {
      String nodeName = System.getProperty("jboss.node.name");
      logger.info(nodeName);
    }
  }</code></pre>
  
  <p>From the log files I can see that the bean is correctly deployed on the cluster. On the client side I then create a number of threads that lookup and invoke an instance of <code>TestEJB</code>. However, it appears that all instances end-up in the same node.</p>
  
  <p>Here's the "jndi.properties" file:</p>
  
  <pre><code>java.naming.factory.url.pkgs=org.jboss.ejb.client.naming</code></pre>
  
  <p>And "jboss-ejb-client.properties":</p>
  
  <pre><code>endpoint.name=client-endpoint
  remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
  
  remote.connections=default
  remote.connection.default.host=192.168.0.1
  remote.connection.default.port=4447
  remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
  remote.connection.default.username=user
  remote.connection.default.password=pass
  
  remote.clusters=ejb
  remote.cluster.ejb.clusternode.selector=org.jboss.ejb.client.RandomClusterNodeSelector</code></pre>
  
  <p>In the client I do <code>final InitialContext ctx = new InitialContext();</code> and then form within each thread:</p>
  
  <pre><code>String name = "ejb:/test//TestEJB!" + TestEJBRemote.class.getName();
  TestEJBRemote remote = (TestEJBRemote) ctx.lookup(name);
  remote.test();</code></pre>
  
  <p>What is it that I'm doing wrong?</p>
  
  <p><b>UPDATE</b></p>
  
  <p>If I specify only the second node in the connection list, I get:</p>
  
  <p><code>java.lang.IllegalStateException: No EJB receiver available for handling [...] combination for invocation context org.jboss.ejb.client.EJBClientInvoc
  ationContext</code></p>
  
  <p>So probably this issue needs to be resolved first...</p>
  
  <p><b>UPDATE 2</b></p>
  
  <p>I solved the problem eventually, by setting up an <i>application user</i> in the slave node. Before, I was trying to connect as the management user, which didn't work.</p>
  
  <p>The load-balancing now works as well, as long as I specify a slave node in the connection list (in "jboss-ejb-client.properties"). If I specify the master node, all EJBs will end-up in that node only. This solution is sufficient for me, however.</p>