11 Replies Latest reply on Aug 19, 2003 1:13 PM by slaboure

    JNDI lookup problem

    radhikamehta

      hi! I have a standalone java program which tries to lookup a sessionbean deployed in jboss3.2.0 in a remote machine.
      I am using cluster configuration.
      My java code snippet is:

      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, "xxx.xxx.xxx.xxx:1100"); // HA-JNDI port.
      Context ctx = new javax.naming.InitialContext(p);
      Object ref = ctx.lookup("abc");

      My problem is that it gives a communication exception during lookup.
      The exception is::


      javax.naming.CommunicationException. Root exception is java.rmi.RemoteException
      : Service unavailable.
      at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClien
      t.java:165)
      at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java
      :203)
      at $Proxy0.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)

      Can someone please help???
      Thanx in advance
      Regards,
      Radhika Mehta

        • 1. Re: JNDI lookup problem
          monu

          I am able to lookup a remote ejb from a standalone java progarm. I have written something like this:

          Properties props = new Properties();
          props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

          props.put(Context.PROVIDER_URL, "RemoteServer:1100");
          props.put("java.naming.rmi.security.manager", "yes");
          props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
          Context ctx =new InitialContext(props);
          HelloHome home = (HelloHome) ctx.lookup("Hello");

          Regards,
          Monu

          • 2. Re: JNDI lookup problem
            radhikamehta

            I just found that we have to configure the machine IP in deploy/cluster.xml. I was not able to lookup coz of this
            problem, though I think this should not have been there..
            well it is working now :-)

            • 3. Re: JNDI lookup problem
              slaboure

              what do you mean? There is no such thing to do to make it work.

              sacha

              • 4. Re: JNDI lookup problem
                buckman1

                Maybe I am missing something, but we use a jndi.properties file, and all of our ports indicate :1099, not :1100. I am having no problems connecting from our fat Swing client to the various jboss clustered nodes (4 in total) with nothing more than specifying the ip:1099,ip2:1099,ip3:1099 in the jndi.properties file.

                Am I not understanding something here?

                • 5. Re: JNDI lookup problem
                  slaboure

                  yes, but if you want to really use HA-JNDI and not simply JNDI, either:
                  - indicate :1100
                  or
                  - indicate NOTHING AT ALL

                  in the last case, automatic discovery will be used.

                  Cheers,


                  sacha

                  • 6. Re: JNDI lookup problem
                    buckman1

                    Interesting. We have been using 1099 and it seems to work. What does using 1100 do in terms of clustering that 1099 doesn't?

                    • 7. Re: JNDI lookup problem
                      slaboure

                      the proxy is non-clustered and if something is bound to HA-JNDI and not JNDI, it will not be found. In the same way, if something is bound to only ONE of the JNDI tree (non-homogeneous deployment), it may not be found if you are not using the good JNDI tree.

                      cheers, sacha

                      • 8. Re: JNDI lookup problem
                        sdev

                        Hi,
                        I deployed a stateless sb with tag as true in jboss-3.0.7_jakarta-tomcat-4.1.24. I have written a standalone client to lookup the bean by using the HA-JNDI context on 1100 port.

                        Still i am getting a javax.naming.NameNotFoundException from org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:214)

                        Interestingly, if i try to lookup the bean using context on port 1100 without enabling the cluster setting for the bean in jboss.xml, the lookup is working fine.

                        Am i missing any configuration.

                        Thanks in advance.

                        • 9. Re: JNDI lookup problem
                          sdev

                          I managed to figure out the problem. It was due to conflicting classes in the classpath. The lookup is working fine now.

                          • 10. Re: JNDI lookup problem
                            satish_misc

                            I am getting exactly the same problem. Can you explain what do you mean by 'conflicting classes'?

                            • 11. Re: JNDI lookup problem
                              slaboure

                              make sure your classpath is EMPTY when starting JBoss