10 Replies Latest reply on Jan 22, 2007 6:05 AM by Michiel Graat

    Error connecting to ejb3 cluster

    Alex Levine Newbie

      I am currently using jboss-4.0.4.GA on debian linux with the ejb3-clustered configuration. Whenever I try and get a remote client to use a session ben running in my server it fails. It first successfully connects to the JNDI port and receives a session stub back, but then when a mehtod call is attempted I get exceptions saying that it could not establish a connection. When I run client on the same host as the clustered jboss then it woks fine. I then noticed that if I am running a jboss on machine A and a jboss in a separate cluster on machine B, and then I run the client on a but pass the address of B into the jndi properties hashtable, The client appears to do teh jndi lookup on B but then connect to A and run. Upon further examination I set up trance loggin on my client and saw that the client stub that is loaded via jndi is trying to connect to the loopback address instead of the ip address of the server it did the lookup on.

      Essentially this is what seems to be happening:
      1. Client on A gets session stub from server on B via JNDI
      2. Server sets the clientBindAddress to the loopback address instead of the actual IP of the server
      3. session stub then tries to connect to its own loopback address where there is no server running and therefor gets connect exception.


      How do I fix this??? I have looked at the following similar post: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=82345 and tried different combinations of the ideas in there but to no avail. Any suggestions would be greatly appreicated.\

      -Alex

        • 1. Re: Error connecting to ejb3 cluster
          Alex Levine Newbie

          After trying several more permutations I finally got it to work with the ejbs by changing the line
          socket://${jboss.bind.address}:3873

          to

          socket://my_ip:3873

          in ejb3.deployer/META-INF/jboss-service.xml.

          Then similary for jms, I had to update it in the file:
          jms/uil2-service.xml


          I noticed that the jboss.bind.address was always 0.0.0.0
          I then looked in the jboss invoker code and noticed that in the case that the address passed into the invoker is 0.0.0.0 then it uses:
          InetAddress.getLocalHost.getHostAddress()
          to get the address to pass back to the session stub as the address to connect to. On many linux distributions, the above code gives the result 127.0.0.1 while on windows it will give you the actual ip address of the machine. I think that may have been why remote clients were attempting to connect to the loopback address.


          Rather than setting the ip of the machine in each of the files, is there a way to just set jboss.bind.address??

          • 3. Re: Error connecting to ejb3 cluster
            Alex Levine Newbie

            upon further notice this seems that it may be primarily an issue with debian linux. When I tried the same set up on ubuntu linux, the jboss.bind.address resolved properly to the address of the machine instead of the loopback address. Has anyone else seen this happen?? Is there potentially something that I can fix in my linux configuration to result in the address being resolved correctly?? If this cannot be addressed then, once again, is there some way to set the jboss.bind.address variable??

            • 4. Re: Error connecting to ejb3 cluster
              Tom Elrod Master

              You can either use the -b option for setting the bind address (e.g. >./run.sh -b 192.168.1.2) which will bind all network services to the specified address or set a system property for jboss.bind.address (for example, put -Djboss.bind.address=192.168.1.2 in the run.sh file). BTW, any alias found within a configuration xml file (such as ${jboss.bind.address}) can be set using system propreties.

              • 5. Re: Error connecting to ejb3 cluster
                Lea Dobbins Newbie

                I have an interesting similar problem. We are setting the jboss.bind.address property in the run.sh (-Djboss.bind.address=${HOST_NAME}). Our Solaris machines have two ip address - one that is routed to a "data" network, another to an "admin" network. Our admins have configured ip aliases in the DNS that they want us to use instead of ip addresses. We set the HOST_NAME parameter in a script that calls run.sh depending on which machine we are deploying to.

                On our development machine, the jboss.bind.address is getting set correctly - I can view the properties via the JMX console and see the property value.

                On our other machines (test and prod), the jboss.bind.address comes up as 0.0.0.0. We are running JBOSS 4.0.1 SP1.

                Why would the IP address be getting resolved on two of the machines, but not on the other? Any ideas?

                • 6. Re: Error connecting to ejb3 cluster
                  Tom Elrod Master

                  Just a guess, but sounds like dev machine and test/prod are using different script env (i.e. Solaris uses bourne shell, which I think needs -Djboss.bind.address=$HOST_NAME).

                  • 7. Re: Error connecting to ejb3 cluster
                    Jens Elkner Apprentice

                    Nope. On standard bourne shells "${HOSTNAME}" == "$HOSTNAME" is always true.

                    • 8. Re: Error connecting to ejb3 cluster
                      Alex Levine Newbie

                      I've noticed that on my companies linux machines
                      (which are using debian sarge linux dist.), using the hostname does not work here. You need the IP address, otherwise it resolves to the loopback address and remote connections do not work. The only solution we could get to work was using the -b option followed by the machine's ip address. Meanwhile, on my home setup (which uses ubuntu linux) the hostname resolves just fine to the actual IP address of the machine with out needing to specify the IP address anyhwere in the config or startup.

                      Another difference that I noticed was that when things worked without specifying the ip address the following code would result in the actuall ip address of the machine:
                      System.out.println(InetAddress.getLocalHost().getHostAddress());

                      while on the machines where the hostname would not resolve properly the above code would result in the loopback address being returned.

                      This points to it being either a java security issue as noted in the java docs fot InetAddress.getLocalHost (although the java security settings for both of the different types of linux that I tested on appeared to be the same, yet with different localhost ip resolution results) or a machine setup issue or a difference in the Unix/Linux flavors being used.

                      • 9. Re: Error connecting to ejb3 cluster
                        Rob Hasselbaum Newbie

                        Hi all,

                        I have encountered a similar problem on Ubuntu Edgy. I have a web app that listens for browser connections on port 8345. But apparently, it is binding to the loopback interface because I can only connect via "localhost" on the same machine.

                        I have tried specifying -Djboss.bind.address=<my_ip_address> at startup, but it does not seem to have any effect. And even if it did work, I need a solution that is DHCP-friendly because this is a development workstation.

                        Any ideas? For what it's worth, I'm running JBoss under Eclipse/JBoss-IDE, so I am specifying the jboss.bind.address as a VM argument in the launch configuration. I'm passing in other arguments there, too, so I know this technique works with other system properties. Also, I'm not running as root, if that makes any difference.

                        Help would be greatly appreciated!

                        • 10. Re: Error connecting to ejb3 cluster
                          Michiel Graat Newbie

                           

                          "rhasselbaum" wrote:
                          I have tried specifying -Djboss.bind.address=<my_ip_address> at startup, but it does not seem to have any effect. And even if it did work, I need a solution that is DHCP-friendly because this is a development workstation.
                          Using -b <your_ip> doesn't work either?

                          Anyway, it seems this problem is related to the /etc/hosts file on linux systems. In many installations I encountered the first line showed something like:

                          127.0.0.1 localhost.localdomain localhost <your_hostname>
                          


                          This is probably what makes JBoss bind itself to 127.0.0.1. If you want to change this behaviour, just edit /etc/hosts to resemble something like this:

                          127.0.0.1 localhost.localdomain localhost
                          <your_ip> <your_hostname>
                          


                          This worked in all cases I encountered. Unfortunately I don't know how to fix this problem permanently when you're using DHCP, but I guess there is more information to be found on this subject on the Internet. Maybe just leave your hostname out of /etc/hosts?