We have applications running on a jboss and tomcat on the same machine.
Now we want to run them on separate servers.
I tried changing the localhost in the properties to the other machine like this
// Get a naming context
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
prop.setProperty("java.naming.provider.url","otherserver:1099");
prop.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext jndiContext = new InitialContext(prop);
// Get a reference to the Gebruiker Bean
Object ref = jndiContext.lookup("ejb/Session");
but I get the following error
Naming Exception caught: javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to h
ost: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
Naming Exception caught: javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to h
ost: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
Naming Exception caught: javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to h
ost: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
WHY IS IT TRYING TO CONNECT TO THE LOCALHOST AND NOT TO THE OTHERSERVER IF I DIDN'T PLACE IT IN THE PROPERTIES?
I think I missed something in one of the config files.
Is there somewhere some documentation on this issue?
We have the documentation subscription, but I couldn't find the documentation for this issue there (or I missed it).
Regards
Kristof
Look at /etc/hosts on the JBoss server.
There is an answer to this problem in the FAQ forum.
The cause is X/Windows doesn't optimise local traffic
so Redhat changed the host config to trick it into
using loopback and this confuses RMI.
Regards,
Adrian