6 Replies Latest reply on Feb 19, 2004 7:25 AM by Nicholas Whitehead

    client connection to cluster with HA-JNDI multicast

    Peter Goetz Newbie

      Hello Forum,

      I have a little problem connecting my client to a jboss cluster via HA-JNDI.

      But first the configuration:

      I have two Mac OS X machines where there is one instance of JBoss running with a modified "all" configuration on each. These instances run in an extra cluster-partition
      My client runs on a Windows XP machine.
      When I address one server explicitly by adding his url in the jndi-properties, everything works fine. My client is able to lookup everything he wants to.
      But when I change the url to "" and try to connect to the cluster I get the following stacktrace:

      javax.naming.CommunicationException: Failed to connect to server 0.0.0.0:1100. Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 0.0.0.0:1100. Root exception is java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:169)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:426)
      at java.net.Socket.connect(Socket.java:376)
      at java.net.Socket.(Socket.java:291)
      at java.net.Socket.(Socket.java:199)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:186)
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1107)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1192)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at de.kaobe.client.TestClient.main(TestClient.java:32)

      Now I'm wondering what happens there. I searched for the 0.0.0.0:1100 url in the jboss log and have found it at the start of JBoss. JBoss tells me it is listening on that address with the naming service.

      I searched the Forums for this problem but found no answer that helped me. But I have checked the following things that were answered to similar problems:

      I checked that all libraries are the same on client and server.
      I changed the jndi-properties when adding the properties inside the source as well as the jndi.properties of the client and initiated the lookup with the appropriate call (with or without properties HashMap)

      Any help would really be appreciated because I don't know where to get on with changing my environment.

      Thank you all for your help in advance,

      Peter

        • 1. Re: client connection to cluster with HA-JNDI multicast
          jfnormand1 Newbie

          Hi,

          I had the same problem, and the solution was to add jbossha.jar in my classpath.

          Do you have this jar already included ?

          Jean-Francois

          • 2. Re: client connection to cluster with HA-JNDI multicast
            Peter Goetz Newbie

            Hi Jean-Francois,

            thank you very much for your hint. But unfortunately that was not the solution.
            I already had the jbossha-client.jar in my classpath and added the jbossha.jar, but it didn't work. I get the same exception as before.

            Does anybody have other hints for me?

            Thank you very much!

            Peter

            • 3. Re: client connection to cluster with HA-JNDI multicast
              jfnormand1 Newbie

              What happens if you specified an address ?

              Like:

              env.put(Context.PROVIDER_URL, "test.host.com:1100");

              Jean-Francois

              • 4. Re: client connection to cluster with HA-JNDI multicast
                Peter Goetz Newbie

                Good morning Jean-Francois,

                when I specify an existing adress everything works fine.
                I get my connection and can work.

                Do you think it might be the multicasting that makes the problem? But multicasting works, because I have tested it with the machines in my office (the same that should now communicate).

                Peter

                • 5. Re: client connection to cluster with HA-JNDI multicast
                  marc fleury Master

                  this should really be a faq, it seems it is tied to the configuration of jgroups? Bela if you read this can you enter a FAQ question on absolute IP versus localhost stuff? Is this making sense to you

                  • 6. Re: client connection to cluster with HA-JNDI multicast
                    Nicholas Whitehead Novice

                    We saw this problem recently. For some reason, the HAJNDI service's BindAddress attribute is initializing to 0.0.0.0. Actually, it seems to be hard coded that way, unless you override it with the startup option --host=<ip address>.

                    So with some debugging of the source code, I realized that the jnp naming context actually gets delivered the 0.0.0.0[:1100] address by the HAJNDI auto discovery listener, preventing the auto discovery recipient client from connecting.

                    The --host=<ip address> fixed the problem (once I realized that for some reason, only %1 and %2 were being passed to the java call in run.bat :( )

                    The docs imply that the --host=<ip address> is only necessary on multi-homed machines, but in this instance, I would say it is mandatory. Alternately, HAJNDI should be changed to acquire a real IP address for it's BindAddress attribute.

                    This was observed on Win XP, but the problem, I think, is this:

                    1. HANamingService.AutomaticDiscovery.run() listens on the multicast port for auto disc. requests.
                    2. When it gets one, it replies with the ip address determined ultimately from the the cluster-service.xml HANaming service entry, BindAddress.
                    3. In the default distribution, this value is configured as ${jboss.bind.address}.
                    4. org.jboss.Main hard sets this value to "0.0.0.0" at startup unless the --host=<ip address> option is used, in which case, it is set to <ip address>.

                    Sorry for the rambling, and if I have incorrectly maligned someone's code.

                    Cheers.

                    //Nicholas