This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Distributed Java and the fly likes RMI through port forwarding router Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI through port forwarding router" Watch "RMI through port forwarding router" New topic
Author

RMI through port forwarding router

Matthew Fleming
Greenhorn

Joined: Oct 29, 2009
Posts: 8
Hi,

I'd really appreciate some help with the following. I have several java applets that each use an RMI server. This has been working find in a configuration where the server's DNS name is bound to its static IP address. Now, however, I am trying to use a configuration where the server's DNS name is bound to the static IP address of a cable modem, which is connected to a router, to which the server is attached. That is, flemingdp.com is bound to the static IP address 98.103.241.186 (the address of the cable modem), while the server has the static IP address 192.168.0.4 on the subnet created by the router. The router port forwards the rmiregistry port (1099) and the listening ports for the rmi servers (10099, etc) from 98.103.241.186 to 192.168.0.4. It also port forwards port 80, for example, and apache works. But rmi does not.

In one server, for example, I do
java.rmi.Naming.rebind("rmi://flemingdp.com/com.edermpath.dermpath_client.DataAccess);
where DataAccess extends UnicastRemoteObject and has this as the first line in its constructor:
super(10099,new MyClientSocketFactory(),new MyServerSocketFactory());
I have tried various settings for java.rmi.server.hostname when I start the server, without avail, and have also tried various settings in /etc/hosts.

In particular, when I do this to start the server:

java -Xmx512m -classpath dermpathApplet.jar:ilm.jar:mail.jar:activation.jar:mysql-connector-java-5.1.7-bin.jar -Djava.rmi.server.codebase=file:///var/www/regular/htdocs/dermpathApplet.jar -Djava.rmi.server.hostname=98.103.241.186 com.edermpath.dermpath_client.DPAppletServer &

where 98.103.241.186 is the static IP address of the router, which is bound to flemingdp.com

I get this:

mfleming@s1:/var/www/regular/htdocs$ java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.AccessException: Registry.Registry.rebind disallowed; origin /98.103.241.186 is non-local host

Thanks in advance for your help -- this is really driving me nuts.

Matthew Fleming
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

The problem is not there because of your server but because of the RmiRegistry.
The RMIRegistry does not allow a bind/rebind from any other machine but from the local host.
In your case, you are making the bind request to the router which gets forwarded to the server running rmi registry but the client now becomes the router and not the originating server. So, the RMI Registry thinks that someone (router), apart from the box the registry is running, is attempting a bind and hence rejects it. This is the reason why you get

Registry.Registry.rebind disallowed; origin /98.103.241.186 is non-local host


This clearly tells that RMI Registry takes the client as 98.103.241.186 or your router.

I am not sure why while binding you want to go to through the router. I assume the router path is for external clients, yes/no?

BTW, is your server and RMI Registry running on the same box? If not, then this will not work.


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI through port forwarding router