11 Replies Latest reply on Mar 16, 2004 4:23 PM by luigifonti

    Remote clients JNDI problem

    luigifonti

      I'have an old problem, already posted in this forum without finding a solution.

      I Installed Jboss 3.2 on a Linux machine. The deployed applications can only be reached from local clients. Remote clients always get an object not found exception.

      jmx-console sees all the objects correctly bound.

      I've tried all the possible ways to define a jndi environment on the client side (jndi.properties, and different source level solutions):

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=192.168.0.170:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
      props.setProperty( "java.naming.provider.url", "jnp://192.168.0.170:1099" );
      props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      Context jndiContext = new InitialContext(props);

      env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL,"192.168.0.170:1099");
      env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      InitialContext jndiContext = new InitialContext(env);

      But none of them changed the result. What I'm asking now is the following:

      Is there a way to get the list of names of EJB's bound in jboss , using a remote client ? (not jmx-console, which is a servlet, i.e. a local object).

        • 1. Re: Remote clients JNDI problem
          dsengupt

          Your second set seems to be correct. Can you try by doing a "env = new Properties()". Additionally, have you tried by using the environment as VM parameters instead of creating a new Property? Something like -Djava.naming.provider.url=192.168.0.170:1099...etc. etc...

          Additionally, you can also try by doing a System.setProperty on these values and use the default constructor of InitialContext.

          • 2. Re: Remote clients JNDI problem
            luigifonti

            Thanks, but none of your suggestion works, sorry.

            My question is:

            Is there a way to list all the bounded names in jboss server, using a remote client (not jmx-console) ?

            • 3. Re: Remote clients JNDI problem
              darranl

              Have a look at the JNDI API.

              • 4. Re: Remote clients JNDI problem

                context.listBindings()

                Regards,
                Adrian

                • 5. Re: Remote clients JNDI problem
                  luigifonti

                  Yes I have already tried Context.list() and Context.listBindings(), but these methods require a name as parameter. What a name should I pass as parameter to list all the bindings ? I tried with "*", with "all" and more, but the result is always the same: object not found in table.

                  All the jboss installations I made on Windows XP work perfectly. Only this one on Mandrake Linux ha this crazy problem.

                  • 6. Re: Remote clients JNDI problem

                    Try ""

                    Also check /etc/hosts for
                    127.0.0.1 localhost myhost.com
                    then read the FAQ forum

                    Regards,
                    Adrian

                    • 7. Re: Remote clients JNDI problem
                      luigifonti

                      OK, I tried now Context.listBindings(""), i.e. the empty name which should represent the Context itself.

                      Again, I have the error: object not found in table.

                      I am sure the problem is not on client side: if I try with different external servers (Win XP), things work. Only that damned server on Mandrake Linux gives this kind of problem.

                      Do you know if there are working jboss servers on that platform ?

                      • 8. Re: Remote clients JNDI problem

                        Exactly. With the config I show above, the server will tell the client to connect to
                        itself. i.e. 127.0.0.1

                        You can get more details if you enable
                        log4j TRACE logging for "org.jnp" on the client.

                        Regards,
                        Adrian

                        • 9. Re: Remote clients JNDI problem
                          luigifonti

                          OK, I've found a trick to get it working !

                          in /etc/hosts I wrote:

                          192.168.0.170 localhost

                          in place of:

                          127.0.0.1 localhost

                          i.e. I assigned to 'localhost' the address defined by DHCP.
                          But if the address changes, should I edit /etc/hosts every time ?

                          • 10. Re: Remote clients JNDI problem
                            luigifonti

                            I have seen that this problem is not specific to jboss, but more generally involves RMI.

                            With localhost defined as 127.0.0.1 in /etc/hosts, RMI based servers refuse servicing the requests, and force remote clients to address the node 127.0.0.1 (i.e. the client itself).

                            If you assign to localhost the real machine IP address, things work.

                            I would like to know if this is a Mandrake bug, or more generally a Linux bug.

                            • 11. Re: Remote clients JNDI problem
                              luigifonti

                              I have found a better solution now. In /etc/hosts, I added a second line associating the real IP address of the Linux machine to an IP name, instead of changing the localhost definition:

                              127.0.0.1 localhost
                              192.168.0.170 myhost.com

                              With this addition things work fine.
                              Loooking around in forums I have seen that this is a well known problem with jboss under linux, and it should be listed in FAQ.

                              Luigi Fonti