Connection refused to host: 127.0.0.1
When attempting to use JMS or RMI remotely, you might run across an exception that looks like this:
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1
After you have correctly set your client to use a remote host, either by creating a jndi.properties in your classpath that looks like:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=jnp://YOUR-SERVER:1099
Or, by explicitly setting properties for your InitialContext in code:
import java.util.Properties; ... Properties properties = new Properties (); properties.put(Context.PROVIDER_URL, "jnp://YOUR-SERVER:1099"); ... Context context = new InitialContext(properties);
This is the result of a problem in the JBoss server side configuration. You're successfully talking to the correct server, but it does not know its own hostname or IP address.
-b option for run.bat/run.sh enables us to tell JBoss the host it is running on. That solves this problem.
Eg. run.bat -b192.168.9.6 -Djboss.bind.address=0.0.0.0
(the 2nd parameter makes jboss server accessible from remote clients)