7 Replies Latest reply on Dec 20, 2006 7:39 AM by saho

    HA-JNDI Lookup doesn?t work from other (not the binder)Servi

      Hi All,

      If I create the HA-JNDI Context Set and then rebind the object to HA-JDNI the lookup within the same service works, but from other service if I create the same context Set the lookup doesn?t work(NameNotFoundException).
      So what I make wrong, I don?t understand?
      Here is my code


      Properties p=new Properties();
      p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      p.put("java.naming.factory.url.pkgs", "jboss.naming:org.jnp.interfaces");
      p.put("jnp.partitionName", Partition);
      InitialContext ictx= new InitialContext(p);

      ictx.rebind(?myService?, serverObject);
      ictx.lookup(?myService?);
      // this works

      But from other service the lookup to this bounded object doesn?t work.

      I use JBoss AS 4.0.4

      Thanks for any Help

        • 1. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

          The first thing you can do is confirm that you've bound the entry into HA-JNDI. If you access the JNDIView mbean from the JMX Console, you can invoke the List method and see if the entry is bound into the HA-JNDI namespace. If it's there, then it should also be bound on your other server.

          If instead, the entry is bound into the Global JNDI Namespace, it would only be accessible from the other server if you used an HA-JNDI server to perform the lookup. Since you didn't specify a HA-JNDI server in your context, you would need to use auto discovery to accomplish this.

          • 2. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

            Thank you Jerry Gauth for your answer,
            i know the JNDIView from the JMX Console. But I can?t see the HA-JNDI there because of this bug http://jira.jboss.com/jira/browse/JBAS-3260 which is fixed on 4.0.5 not for 4.0.4. And I can?t switch to 4.0.5 because every thing is configured and tested under 4.0.4 of the already created projects on JBoss. And the bug occurs when there are nothing in the HA-JNDI registered. But where is it then registered ?
            What I wander is that why, if I register the object in One Service and the lookup works there, even if I close and open again the context Set, but in other Service (by the Same Server) the lookup doesn?t work.
            The Auto Discovery is also enabled.
            Some hints? suggestions ?

            • 3. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

              I wasn't aware of that bug.

              I could be mistaken but I don't think you can use auto discovery to actually bind something into HA-JNDI. If you want to bind explicitly into HA-JNDI, you should add the HA-JNDI provider url to your context object. So you would add an entry similar to the following, using your own server name.
              p.put("Context.PROVIDER_URL", "localhost:1100")

              Note that binding something to HA-JNDI causes the binding to be replicated across all nodes in your cluster. However you don't need to bind an object to HA-JNDI in order for it to be looked up from a remote node. You can bind it locally into the Global JNDI Namespace and use HA-JNDI (with or without autodiscovery) to find it from another node. This requires that you have configured everything correctly, including the cluster itself.

              • 4. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

                One more observation - I took a look at the fix for JBAS-3260 and it stated that the problem occurred when the HA-JNDI service wasn't deployed. So if you're seeing this problem in JNDIView, are you running a clustered server?

                • 5. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

                  Thank you,
                  i have now changed to testing purposes my application to JBoss 4.0.5.
                  Now form JNDI View i see that the object is registered to the HA-JNDI.
                  But still the lookup form other Service doesn?t work, even if i specify the server by the providerURL ("ServerName":1100).

                  Note: I use the all configuration with clustering Services.

                  I have also tried with this context set (from wiki http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHAJNDIUseCluster)

                  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, "localhost:1100"); // HA-JNDI port.
                  return new InitialContext(p);


                  And still i cant?t find(NameNotFound) the object by ictx.lookup(?myobject?); from other Service.

                  I don?t understand what I make wrong, can someone explain me please ?
                  Thaks

                  • 6. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

                    On the client, try prefixing the provider url with jnp://

                    p.put(Context.PROVIDER_URL, "jnp://localhost:1100);

                    If this doesn't help, check your server logs and ensure that your cluster nodes are actually seeing each other.

                    • 7. Re: HA-JNDI Lookup doesn?t work from other (not the binder)S

                      Thank you Jerry Gauth for your so quick Answer,
                      Now works, with ?localhost:1100? .
                      The Problem was that JBoss doesn?t really apply my changes in the Sar file (Hot deployment doesn?t work properly).
                      After every changes I must restart the JBoss.
                      Which was confusing because JBoss AS starts and stops the Service by replacing the Sar file, but my changes wasn?t applied.