Problems with RMI and JWS

Hi!

I am currently working on a client/server RMI project. The server module is starting RMIRegistry at the server host and waits for clients to connect.

The client connects the server by RMI and registers a RMIService for the server to call in the client.

The client may call methods in the server.

The server may call other methods in the client.

This worked great until we introduced Java Web Start.

There is no way of setting the java.rmi.server.hostname system property due to security reason from inside the jws sandbox.

The reason for doing this is to force the JVM to specify the correct IP-address in the service provided for the server. The server fails connecting the client when calling clientmethods because the client host has several IP-addresses. (ie. VPN + ISP address)

We used to set this by doing a System.setProperty call but this is now prohibited. Is there a way to force a UnicastRemoteObject to use another IP than getLocalHost().. getLocalHost returns the wrong IP!!

[1047 byte] By [Tomas_Andersena] at [2007-11-26 16:42:14]
# 1

Hello Tomas,

since you can't set the java.rmi.server.hostName property inside the sandbox, a technique I have found useful is to create a custom RMICientSocketFactory that takes a fixed address in its constructor. It uses this value when it creates sockets, instead of the default of using the server hostName property value.

Quite a few other issues will crop as you progress, if you are interested, here is a [url = https://cajo.dev.java.net/tutorial.html]link,[/url] to a fully functional example, including source code. It just might help get you up and running more quickly.

Good luck,

John

cajoa at 2007-7-8 23:09:19 > top of Java-index,Core,Core APIs...