tags:

views:

740

answers:

1

I have a client-server setup. The client must be able to bind certain objects to the RMIRegistry. Here is the server side code:

if (System.getSecurityManager() == null)
  System.setSecurityManager(new RMISecurityManager()); 

System.setProperty("java.rmi.server.hostname", "192.168.0.99");

registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
registry.rebind(getRegistryNameImpl(), this);

It binds itself to the registry because I want to use client side RMI calls to bind new objects to the registry.

When I call the rebind methods on the client I get this exception:

java.rmi.ServerException: RemoteException occured in server thread; nested exception is:
    java.rmi.AccessException: Registry.Registry.rebind disallowed; origin /130.126.127.94 is non-local host

How do I avoid t his AccessException?

A: 

I solved this problem by using the Naming.rebind convention instead of registry.rebind. It seems that Naming.rebind may be less strict about security.

RyanTM
Having looked at the Naming.java source, it doesn't appear that there's any real difference in security handling (it's really just a wrapper for a Registry.rebind() call). Are you sure that you didn't have a bug in your original client code?
Bob Cross
I also tried to change it to Naming.rebind, but i get the same exception.
Maerch