8 Replies Latest reply on Jun 7, 2006 5:38 AM by visolvejboss

    Connecting from one server to other

    s.rzytki

      Hello
      I have two servers one which makes available some services, and second server which contain ordinary web application. Some part of web application need to access to remote server (through JNDI) so i configured access to jndi like below:

      Properties jndiProperties = new Properties();
      jndiProperties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      jndiProperties.put("java.naming.provider.url", serverAddress;
      InitialContext context = new InitialContext(jndiProperties);


      When I initialize my InitalContext in way like above, I get connection to local jndi not to my remote server jndi advisable through serverAddress parameter.

      Problem is I can't override configuration for InitialContext context which is used to lookup local services from jndi for web application.

      I'll will glad for any suggestion.

      Thanks Sebastian

        • 1. Re: Connecting from one server to other

          You can use HA-JNDI instead of a local JNDI address if you're running in a cluster. If you know which server to use for various lookups, you might also try creating initial contexts for each server and use the one appropriate for each lookup.

          • 2. Re: Connecting from one server to other
            s.rzytki

            I tried to create two InitialContext but when i try to connect to remote jndi I get connection to local jndi (situation was described in post above). Please write some code examples.

            Thanks
            Sebastian

            • 3. Re: Connecting from one server to other

              Code like the folloiwng should be sufficient to direct your JNDI lookups to a specific server. Change the provide url as needed.

              You can use HA-JNDI by using the HA-JNDI port in the url. By default, this is port 1100. Note that HA-JNDI requests may not go to the specified server as HA-JNDI uses round-robin load balancing. This would only matter if you had local entries bound with the same name to different values in which case you wouldn't want to use HA-JNDI.

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

              • 4. Re: Connecting from one server to other
                ljnelson

                I am seeing the same behavior, even with the recommended environment settings.

                In my case, I have some code running on a JBoss 4.0.3SP1 server trying to act as a client to a JBoss 3.2.6 server. Obviously I can't just use the client libraries supplied by JBoss 4.03SP1 for this purpose.

                How would one set up inter-server JNDI communication when the servers may not be from the same vendor, or may be different versions from the same vendor? I would have thought it should be through the environment parameters.

                Laird

                • 5. Re: Connecting from one server to other
                  littlefish

                  Somebody told me that, when you packaging the .war, also pack the "jbossall-client.jar" (the one get from the ejb server jboss) to the WEB-INF/lib should be ok.

                  But i still can't make it work.

                  Anybody knows how to make it work?

                  • 6. Re: Connecting from one server to other
                    jahlborn

                    Hmm, I'm starting to think this is a bug in 4.0.3SP1. I'm having the exact same issue, as i posted in a separate forum:

                    http://www.jboss.org/index.html?module=bb&op=viewtopic&t=83207

                    • 7. Re: Connecting from one server to other
                      niki600

                      What about next situation?
                      I have made an .ear and I want to run client application on the one machine and the JBoss AS on the another.
                      My client machine is called ubuntu with address 192.168.0.4
                      and laptop on which I want to run JBoss AS has an address 192.168.0.5
                      Also on the laptop I have installed Postgres server.
                      I know that I have to set up jndi.properties which must point on the IP address of the machine where exists JBoss AS.But how to force JBoss AS to not listen on the localhost address and to listen on the ethernet address in my case
                      is 192.168.0.5.How to set up /etc/hosts ?
                      If someone could help me I would be gratefull.

                      • 8. Re: Connecting from one server to other
                        visolvejboss

                        Hello,

                        You can make the JBoss AS to listen an particular ipaddress instead of localhost by running the JBoss AS with the following option.

                        $ ./run.sh -b {ipaddress}

                        For your case,

                        $ ./run.sh -b 192.168.0.5

                        Regards,
                        ViSolve JBoss Team