9 Replies Latest reply on Oct 10, 2002 1:02 PM by feldgen

    HA JNDI for MBeans

    feldgen

      Hi,
      I use JBoss 3.0.2 and j2se 1.4.0.
      I set up clustering with HA-JNDI on port 1100 and all three nodes are finding themselves, farming and load-balancing works well.
      Now to my problem:
      I have two MBeans as entrance and exit to/from the EJB-Tier which are running each on only one node (All nodes are in the same partition).
      I register the MBeans in startService() to JNDI as follows:
      (this class extends ServiceMBeanSupport and implements its MBean interface)

      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES,"jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL,""); //for auto-discovery

      InitialContext ic = new InitialContext(p);

      NonSerializableFactory.bind("java:/ExitService", this);
      StringRefAddr addr = new StringRefAddr("nns", "java:/ExitService");
      Reference ref = new Reference(this.getClass().getName(), addr, NonSerializableFactory.class.getName(), null);
      ic.bind("java:/ExitService", ref);

      As described in NonSerializableFactory this will be bound to local JNDI and if this exit runs on the same node as the EJB-Tier everything is ok.

      The HA-JNDI-Lookup is as follows:

      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL, ""); //for auto-discovery

      InitialContext ic = new InitialContext(p);

      ExitMBean exit = (ExitMBean) ic.lookup("java:/ExitService");

      exit.doWork(someObjectPK);

      This MBean is deployed with this jboss-service.xml after the EJB-Tier is deployed :





      This is all made kind of similar to the CounterService in the jboss-cvs...
      I can't see the error why the HA-JNDI lookup won't find this MBean...as i wrote, running only one node works really fine.
      Please be so kind and tell me what error i made.

      Thanks,

      lfeldgen

        • 1. Re: HA JNDI for MBeans
          feldgen

          Hi again,

          does this not-answering to my question mean that my fault is too obvious to tell or does it mean that someone is working on that question and yet had no time to answer?

          Thnx in advance,

          lfeldgen

          • 2. Re: HA JNDI for MBeans
            slaboure

            As you are in-VM, I am not sure if you will actually use the HA-JNDI server by using:

            p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            p.put(Context.URL_PKG_PREFIXES,"jboss.naming:org.jnp.interfaces");
            p.put(Context.PROVIDER_URL,""); //for auto-discovery


            Instead, in Context.PROVIDER_URL, set the actual value (such as localhost:1100) and this should work. I suspect that you current code will only work with the local jNDI tree, not the HA.

            Cheers,


            sacha

            • 3. Re: HA JNDI for MBeans
              feldgen

              I tried this already but I can imagine that HA-JNDI is not deployed at the time my MBean is deployed...
              I'll try that!

              Thnx,

              lfeldgen

              • 4. Re: HA JNDI for MBeans
                slaboure

                then set a dependency tag between your mbean and HA-JNDI

                • 5. Re: HA JNDI for MBeans
                  feldgen

                  Ok, I'll try this, but Bill Burke told me that the non-serializability is a problem too....

                  • 6. Re: HA JNDI for MBeans
                    slaboure

                    What do you mean?

                    • 7. Re: HA JNDI for MBeans
                      feldgen

                      I think he means this part:

                      NonSerializableFactory.bind("java:/ExitService", this);
                      StringRefAddr addr = new StringRefAddr("nns", "java:/ExitService");
                      Reference ref = new Reference(this.getClass().getName(), addr, NonSerializableFactory.class.getName(), null);
                      ic.bind("java:/ExitService", ref);

                      Ok, I managed it to find my ExitService across the cluster, but my new EntranceServiceEJB wich works as wrapperBean behind my Entrance MBean does not really find the Bean-Instances on the other nodes...i can see the HA.-JNDI-lookup on the other node but work is all done lokally...
                      I think i have to check what causes this...

                      • 8. Re: HA JNDI for MBeans
                        feldgen

                        Funny, the forum asks me to login while im logged in. so i dont know if my last post is already saved, it is not displayed...
                        plz accept my apologies if these posts are displayed multiple times:

                        I posted a reply one hour ago but i can't see it...so i try again:

                        I think Bill Burke meant the call to the nonserializablefactory...
                        Nevertheless after changing the JNDI-Names in deployment-descriptor my exit MBean is found from my new wrapperBean ExitSessionEJB...across nodes!
                        So one half of the problem is solved ;)
                        The other half:
                        I have a MBean which gets an amount of requests. every request will be passed (with the homeInterface of my Entrance running on all nodes) to a thread which calls a new EntranceSessionEJB to delegate these requests to the entrance...
                        I think this should work, but if there is a design error plz tell me ;)
                        This entry-point handling works well with one node. the problem with many nodes is that i can see "HA-JNDI lookupLocal" on other nodes but the work is done on the node with this entrance.
                        Is anything in my design with the threads which prevents load-balancing? I read loads in the forum but i couldn't figure out if maybe the round-robin is the cause or if this "load-balancing is made per client" is the part that i misunderstood...
                        Thnx for any help,

                        lfeldgen

                        • 9. Re: HA JNDI for MBeans
                          feldgen

                          I found a workaround for my last problem, but maybe this could be solved better:

                          The fact that my HA-JNDI-lookup from the MBean outside my application finds the desired beans already in local JNDI prevents it from using the beans on other nodes.
                          My workaround is not to deploy my application on the node where the mbean is running, so that a real HA-JNDI-lookup is performed and load-balancing is used.
                          This splitting of entrance and application is not what i really want, so if anyone has some better ideas, they are really welcome ;)