3 Replies Latest reply on Jul 7, 2016 10:21 AM by Robert Benkovitz

    Lookup HA Singleton in a cluster

    Robert Benkovitz Newbie



      I have a HA Singleton deployment in a WildFly 10 cluster, using the 'old school' deploy-hasingleton feature of AS6 and earlier.  In a JBoss 5.1 deployment, an application deployed in the cluster would look up this singleton by looking up the jnp partition where HA-JNDI was registered.  This would return an InitialContext which would be able to look up the singleton bean no matter what node of the cluster it is deployed to.  Here is the code snippet:


      public static InitialContext getHAInitialContextWithinServer() throws NamingException {
        Properties p = new Properties();


      // HA-JNDI is registered under the partition name passed to JBoss via -g 
      String partitionName = System.getProperty("jboss.partition.name", "DefaultPartition");
      p.put("jnp.partitionName", partitionName);


      return new InitialContext(p);


      With WildFly 10, using the 'default' InitialContext lookup will (obviously) get the local JNDI tree, so if the request is from a node where the singleton is NOT deployed, it will fail (expected of course). I cannot figure out how to look up the singleton from a node in the cluster without somehow sending the entire information about the cluster (i.e. all node information).


      Is there an equivalent HA-JNDI lookup I can do from any node in the cluster?


      Thanks for any help.

        • 1. Re: Lookup HA Singleton in a cluster
          Paul Ferraro Master

          So, you have a @Remote EJB packaged in a jar, which is deployed as a singleton deployment, correct?


          The remote EJB will behave as if it is only deployed on one server.  Provided that you follow the instructions here, the location of the EJB should be completely opaque to you:

          EJB invocations from a remote server instance - WildFly 10 - Project Documentation Editor

          • 2. Re: Lookup HA Singleton in a cluster
            Robert Benkovitz Newbie

            First, thank you for the quick reply.  Yes, you are correct - I have a @Remote EJB packaged in a jar deployed as a singleton deployment.


            Second, I have tried your suggestion - according to the instructions, I created a remote-ejb outbound-socket-binding in a socket-binding-group (in my case, full-ha-sockets).  I've also created a new remote-outbound-connection referencing the remote-ejb outbound-socket-binding-ref.  Additionally, I've added the jboss-ejb-client.xml file to my META-INF folder of the "client" application.  Unfortunately I am getting the same result - lookups of the singleton bean from other nodes fails.


            A couple of questions:


            1) any way to see if it is actually using the bindings?

            2) Even if it uses the binding, the remote-destination set in the outbound-socket-binding is set to basically the first node, so if the singleton is not on that node, how would it go about looking it up?


            Thanks again.

            • 3. Re: Lookup HA Singleton in a cluster
              Robert Benkovitz Newbie

              Follow up:  Turns out I needed to implement the security piece laid out in the link above by Paul in order for it to work (although I might be able to turn security off, not sure about that).  However, I also needed to go a bit further and implement multiple remote-destination and outbound-socket-binding entries, one for each node in the cluster, in order for the lookup to find the singleton.  It seems to work fine - I assume it basically polls each remote-destination to find the bean, and seamlessly moves to the next entry if the current one results in a failure.


              Thanks again for the help.