Problems connecting to an RMI server

Asked

Viewed 143 times

1

On the server RMI I have the following settings:

Registry r = LocateRegistry.createRegistry(rmiport);
r.rebind(rminame, h);
System.out.println("Servidor RMI pronto:");

where, rmiport = 7000 and rminame=sistemas

In client I have the following settings:

System.out.println(rmiServerName);
 h = (ServerInterface) Naming.lookup(rmiServerName);

where, rmiServerName=rmi://194.210.172.185:7000/sistemas

But when I try to call I get the following exception:

RemoteException.

My goal is to be able to connect a client to the RMI server on different machines.

1 answer

1


On the RMI Server put this code:

System.getProperties().put("java.security.policy", "policy.all");
System.setSecurityManager(new RMISecurityManager());
System.setProperty("java.rmi.server.hostname", MEU_IP);
RMIServer rmiServer = new RMIServer();
Registry r = LocateRegistry.createRegistry(rmiport);
Naming.rebind(rminame, rmiServer);

On the RMI client put this code:

System.getProperties().put("java.security.policy", "policy.all");
System.setSecurityManager(new RMISecurityManager());
h = (ServerInterface) Naming.lookup(rmiServerName);

With this the server can already be connected from another machine.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.