views:

25

answers:

1

Hi,
I am using the basic RMI-based client/server app shown in Java Tutorials. I am running the server and client on different machines. I also export the remote objects for both the server and client, and make them available to each other.

However, there is a firewall turned on the client side and so the RMI calls fail (from client to server or server back to client). Also, when the machine has Windows 7 instead of WindowsXP, just allowing the popup message from firewall makes everything run fine. Somehow, the same does not happen on WindowsXP.

I have looked at http://download.oracle.com/javase/6/docs/technotes/guides/rmi/faq.html#firewall mentioned in other similar questions and I am trying the fixed port approach (where in remote object listens on a fixed port).

The code is something like this:

Server

Compute engine = new ComputeEngine();  
Compute stub = (Compute) UnicastRemoteObject.exportObject(engine,1299);  
Registry registry = LocateRegistry.createRegistry(1299);  
registry.rebind("Compute", stub);  

Client

String host = "192.168.x.y";  
Registry registry = LocateRegistry.getRegistry(host, 1299);  
Compute comp = (Compute) registry.lookup("Compute");  
Pi task = new Pi(Integer.parseInt(args[0]));  
BigDecimal pi = comp.executeTask(task);  

Please let me know if you have faced similar problem or if you can point out where I am going wrong.

Thanks,
Abhinav.

A: 

first try comment out this line:

Registry registry = LocateRegistry.createRegistry(1299);

and check do you have security.policy file if not then create that

then try this code in that:

grant {
permission java.security.AllPermission "", "";
};

and might be you are not setting security manager: set that like this in your main method:

System.setSecurityManager(new RMISecurityManager());
Static Void Main