File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes Java RMI problems with multiple NICs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Java RMI problems with multiple NICs" Watch "Java RMI problems with multiple NICs" New topic

Java RMI problems with multiple NICs

Brian Pendell

Joined: Oct 07, 2011
Posts: 9
I have a system running Java SE 1.6U7 on Windows 2008 server. This system has several network interface communication (NIC) cards used for ethernet and TCP/IP communication . We have an RMI application that responds to clients communicating on NIC 1. The other NIC (designated NIC2 ) is on a different network.

When only NIC 1 is enabled we have no problems.

However, when NIC 2 is enabled, I get a connection refused RMI exception. Careful examination reveals the following course of events:

1) Client requests connection on <NIC 1 IP address>
2) Connection rejected on <NIC 2 IP address>

It appears that , when the server registers its service on the RMI registry, the RMI registry is recording it as being available on <NIC 2>, which of course the client can't see at all.

I have attempted to hard-code the rebind() call to NIC 1 IP address. I have also used on the command line to force that system property to NIC 1 address. Neither of these operations helped.

I note that this program has been running for years on Windows 2003 Server (equivalent to Windows XP) without a problem. Perhaps it has something to do with the fact that name resolution, especially of 'localhost', has been revised greatly between the Microsoft versions.

Which leads me to the following questions:

1) Has anyone else encountered this?
2) Will upgrading to the latest version of Java solve this problem?
3) Is there a way to configure the server WITHOUT modifying the java program to ensure that the appropriate NIC appears in the RMI registry?
4) Failing that, is there a way to programmatically force this change? As I said, I have already attempted the usual suspects without success.


Brian P.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

It's most likely that the RMI ports are firewalled on NIC2.

Normally, no network application should be binding to a specific NIC. At best, it should only bind on (listen at) a specific IP address(es).

A server name is not the same thing as an IP address. The two are mappable to each other, but it's not a 1-to-1 mapping.

An IDE is no substitute for an Intelligent Developer.
Brian Pendell

Joined: Oct 07, 2011
Posts: 9
Checked. Firewall was down, so that wasn't the issue.

Eventually solved the problem by setting System.setSystemProperty("java.rmi.server.hostname" ...) directly in the body of the program. This forced the system to use the IP address I specified in that property.

Strange; I would have thought that passing -Djava.rmi.server.hostname= on the command line would have done that as well, only it didn't.

At any rate, the problem is solved.


Brian P.
I agree. Here's the link:
subject: Java RMI problems with multiple NICs
It's not a secret anymore!