5 Replies Latest reply on Apr 15, 2004 2:44 PM by lordbritish

    Can't do JNDI lookup for "/HAPartition"

    lordbritish Newbie

      I am unable to get access to the HAPartition instance doing a JNDI lookup of "/HAPartition".

      I'm doing the lookup from within an MBean.

      I'm running the "all" configuration - run.sh -c all

      I've tried JBoss 3.2.3 and JBoss 3.2.4RC1.

      I'm running on a Solaris SPARC Ultra 10.

      Here's a portion on my code:

      InitialContext ctx = new InitialContext();
      HAPartition myPartition = (HAPartition)ctx.lookup(""/HAPartition");

      This will fail on v3.2.3 and v3.2.4RC1 with an error saying "HAPartition" is not bound. Furethermore when I do a ctx.list on "/", I do not see "HAPartition" in the list - it is simply not there.

      Interestingly, I tried this with JBoss v4.0 R3 and I did find "HAPartition". So either there a configuration setting that is missing or v3.2.3/v3.2.4RC1 is buggy. I don't really understand how somethign like this could pass QA??

      Please tell me that I did something wrong or forgot to do something.

        • 1. Re: Can't do JNDI lookup for
          lordbritish Newbie

          Oh yea, I was tring to get "/HAPartition/DefaultPartition".

          I couldn't get "DefaultParition" because "HAPartition" is not there.

          Seems mighty odd to me !!

          • 2. Re: Can't do JNDI lookup for
            lordbritish Newbie

            This is still unresolved.

            If I don't see a solution soon, I will create a bug report for it.

            • 3. Re: Can't do JNDI lookup for
              Scott Stark Master

              The TopologyMonitorService debug utility which does the same lookup:

               protected void startService() throws Exception
               InitialContext ctx = new InitialContext();
               String partitionJndiName = "/HAPartition/" + partitionName;
               partition = (HAPartition) ctx.lookup(partitionJndiName);
               // Register as a listener of cluster membership changes
               log.info("Registered as MembershipListener");
               hostname = InetAddress.getLocalHost().getHostName();
               catch(IOException e)
               log.warn("Failed to lookup local hostname", e);
               hostname = "<unknown>";

              has no problem with this:

               <mbean code="org.jboss.ha.framework.server.util.TopologyMonitorService"
              10:48:53,906 INFO [MainDeployer] Starting deployment of package: file:/C:/cvs/Releases/jboss-3.2.3/server/all/deploy/topmon-service.xml
              10:48:53,921 INFO [TopologyMonitorService] Registered as MembershipListener
              10:48:53,921 INFO [TopologyMonitorService] Started jboss.test:cluster=DefaultPartition
              10:48:53,937 INFO [MainDeployer] Deployed package: file:/C:/cvs/Releases/jboss-3.2.3/server/all/deploy/topmon-service.xml

              Your probably doing your lookup before the cluster service has created the binding.

              • 4. Re: Can't do JNDI lookup for
                lordbritish Newbie

                This is my MBean:

                public class RMIConfig implements RMIConfigMBean {
                 public void start() throws Exception {
                 System.out.println("======== CALLED START ======");
                 InitialContext ctx = new InitialContext();
                 Object obj = ctx.lookup("/HAPartition/DefaultPartition");
                 RMISocketFactory rmiSocketFactry = RMISocketFactory.getSocketFactory();
                 HAPartition myPartition = (HAPartition) obj;
                 MyService myService = new MyServiceImpl();
                 HARMIServerImpl rmiserver = new HARMIServerImpl(myPartition, "MyService", MyService.class, myService, 3433, rmiSocketFactry, rmiSocketFactry);
                 MyService stub = (MyService) rmiserver.createHAStub(new RoundRobin());
                 ctx.bind("RMI_STUB", stub);
                 System.out.println("======== SUCCESSFULLY STARTED ======");
                 public void stop() throws Exception {
                 System.out.println("======== CALLED STOP ======");

                This is how I configured it in in my user-service.xml file:

                 <classpath codebase="." archives="RMIConfig.jar"/>
                 <mbean code="test.RMIConfig" name="user:service=RMIConfig">

                If I'm trying to access "/HAPartition" before it's inititialed, how do I make sure that it is initialized before it gets to my MBean code??

                Like I said, with JBoss 4.0, my code works - I can find "/HAPartition".

                • 5. Re: Can't do JNDI lookup for
                  lordbritish Newbie

                  Ok, I figured it out:

                  I needed to add this to my MBean config:


                  Hehhe, it's all working now ;)

                  Thx !!