4 Replies Latest reply on Feb 6, 2008 6:24 AM by Thomas Franconville

    Ejb clustered registering

    Thomas Franconville Newbie


      I have difficulties to deploy Stateless Ejb 3 on HA-JNDI.
      If I have well understood, to do that, I only have to put the annotation @Clustered on my Ejb.
      But when I deploy, I see nothing into the HA-JNDI Namespace with the JNDIView.
      I view my Ejb only into the Global JNDI Namespace.

      I have deployed my ear into the farm directory. I have added a service of PojoCache to share data.

      What I have wrong ?

      I have tried to do a lookup into my webapplication to found the ejb: NameNotfoundException

      I have put conf/jndi.properties into my ear with thoses values to use the HA-JNDI.

      Thank to give me clue for my problem/understanding.



        • 1. Re: Ejb clustered registering
          Brian Stansberry Master

          You shouldn't see your EJB in the HA-JNDI namespace. In practice, little or nothing gets bound there; the AS itself binds nothing there.

          HA-JNDI primarily works by allowing a client to connect to any node in the cluster and do a lookup, and it internal can communicate around the cluster to find the requested binding in the Global JNDI namespace on any node. It can also find things in the HA-JNDI namespace, but little or nothing is bound there.

          Don't ever deploy a file named jndi.properties inside the AS; you'll likely break the internal functioning of the AS. Try removing that and see if your problems go away. If your only problem is only finding your bean in the Global JNDI namespace, then you don't have a problem. :-)

          • 2. Re: Ejb clustered registering
            Thomas Franconville Newbie

            OK, thank's for you reply.

            So HA-JNDI is probably not a solution for my problem.
            I am on atypic application.
            My application is running all the time. I want to use the cluster architecture to dispatch memory and cpu use. But I need sometimes to communicate between node. I thought it was possible by Ejb clustered to call the ejb deployed on the node we want.
            I think I will use directly RMI to make this kind of call. What do you think about that ?

            The subsidiary question is, with jmx, is it possible to call a specific node ?
            The application is the same on all nodes except that I want to parametrize the initialization on each node.

            • 3. Re: Ejb clustered registering
              Brian Stansberry Master

              You can call an EJB on another node, except if that EJB is deployed on the node making the call. If the EJB is available locally, JBoss will detect that and optimize the call by routing it to the local bean. In that case your caller wouldn't be able to spread the calls to other nodes in the cluster. If you need a workaround for that, see "Why are calls between clustered session beans not load balanced even though load balancing policy is Round Robin?" on http://wiki.jboss.org/wiki/Wiki.jsp?page=ClusteringFAQ.

              If your client needs to use HA-JNDI to find things on other nodes in the cluster, that's fine. Just don't configure your context via a jndi.properties file. Populate a Map with the key/value pairs you listed and call new InitialContext(Map). You can even externalize the key/value pairs into a .properties file and programatically read in the properties. Just don't name the file jndi.properties. If you put a file named jndi.properties on the classpath, it may be picked up by all sorts of other code and break their JNDI usage.

              You can use JMX to invoke on specific nodes. To make remote JMX calls, use the RMIAdaptor (http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingTheRMIAdaptor). But you'd need to know the address/port JNDI is using on each node in order to find that node's RMIAdaptor.

              • 4. Re: Ejb clustered registering
                Thomas Franconville Newbie

                Thanks a lot for your help.
                I have found this solution:

                I need to launch jboss with a binding address.

                To found the jndi locally we work with, I do this:
                Context jbossCtx = new InitialContext();
                MBeanServerConnection server = (MBeanServerConnection) jbossCtx.lookup("jmx/invoker/RMIAdaptor");
                name = server.getAttribute(new ObjectName("jboss:service=Naming"),"BindAddress") + ":" + server.getAttribute(new ObjectName("jboss:service=Naming"), "Port");

                We share some data associated with our jndi address into PojoCache.
                So we can found distant ejb and call them as we need.
                Hashtable environment = new Hashtable();
                environment.put(InitialContext.PROVIDER_URL, "jnp://" + jndi);
                InitialContext init = new InitialContext(environment);
                ClusteredEjbInterface ejb = (ClusteredEjbInterface) init.lookup("ClusteredEjb");

                CQFD :D

                Many thanks Brian, for your help and your responsiveness.