Problems connecting to an RMI server

1

At 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

On the 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 trying to connect I get the following exception :

RemoteException.

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

    
asked by anonymous 24.10.2014 / 15:55

1 answer

1

In 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);

In 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.

    
26.10.2014 / 17:03