3

I'm running RMI Regitry on a virtual machine (running Windows XP) with IP: 192.168.133.2 and trying to bind an RMI server (running on different vm XP IP: 192.168.133.3) by using this code:

Naming.rebind("//192.168.133.2/rmi.2", new RMI());

where

public class RMI extends UnicastRemoteObject

but I get this exception:

    java.rmi.AccessException: Registry.Registry.rebind disallowed; origin /192.168.133.3 is non-local host

I figured that the RMI Registry don't accept any rmi server which isn't running on the same RMI Registry running machine.

but how to make this registry accept my rmi server?

p.s: I'm using JBuilder X as an IDE.

I'm trying to implement a mobile agent which will run on some rmi servers to do some work on them and return the results to the starting station so RMI servers implements the environment that hosts this agent to do its work and send it to the next station which it'll locate through the registry

Ibrahim.I
  • 229
  • 1
  • 4
  • 18

2 Answers2

4

trying to bind an RMI server (running on different vm XP IP: 192.168.133.3)

Stop right there. You can't do that. You can only bind an RMI server to a Registry running in the same host as the agent that is doing the bind.

Note that that does not necessarily mean the same host as the remote object itself is running in. For example, a client could lookup a remote Registry and bind the stubs retrieved into the local Registry. But you cannot bind anything to a remote Registry.

user207421
  • 305,947
  • 44
  • 307
  • 483
1

RMI doesn't provide any sort of "federated" or distributed naming service.

RMI is structured to allow you to run an RMI registry on your server. It hosts services that can be accessed across the network, however the services run locally on that server.

The service being provided must be started - and "rebind" - on the server - not on any client system. Local address only.

Your clients should then reach out to that server...

Richard Sitze
  • 8,262
  • 3
  • 36
  • 48
  • I'm trying to implement a mobile agent which will run on some rmi servers to do some work on them and return the results to the starting station so RMI servers implements the environment that hosts this agent to do its work and send it to the next station which it'll locate through the registry.. so you say that I can't create a multi-hosts servers (each server running on different machines but on the same network). right?? – Ibrahim.I Dec 12 '12 at 22:37
  • I'm saying each server in your set of 'multi-hosts' must individually run a local rmiregistry to which a local copy of your service is bound. If you want your client to be able to rotate to different RMI services, that's a layer above what RMI provides; you'll have to come up with some way to do that outside of RMI (JNDI naming may be helpful here :-) – Richard Sitze Dec 12 '12 at 22:42
  • but if the agent is running on machine A and want to move to machine B how can it locate B if there is no united registry that contains all the services? – Ibrahim.I Dec 12 '12 at 22:47
  • That's a great question, and one for which RMI doesn't provide an answer. – Richard Sitze Dec 12 '12 at 23:49
  • Your description is close enough to solve this problem, but nevertheless inaccurate. The Registry will only accept `bind/rebind/unbind` requests from processes running in the local host, but there is no requirement that the *objects being bound* are running in the local host. A program could look up objects in a remote Registry and bind them to the local Registry for example; then the local Registry would contain references to servers running in remote hosts. – user207421 Jun 14 '13 at 01:18