When attempting to lookup an EJBHome on JBoss 3.0.3 from a remote client, we were getting the following exception on the client:
javax.naming.CommunicationException. Root exception is
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
After some digging, we found that the problem is that the correct host name is not being bound by the RMI Server in JBoss. There appear to be two solutions:
1. set the "java.rmi.server.hostname" environment variable to the hosts fully qualified name or IP address in the run.sh / run.bat startup script.
2. set the name of the localhost in the /etc/hosts file to be the fully qualified name or IP address
An example of solution 1:
( in run.sh )
FULL_HOST_NAME=`hostname`.`domainname`
JAVA_OPTS="$JAVA_OPTS -Dprogram.name=$PROGNAME -Djava.rmi.server.hostname=$FULL_HOST_NAME"