Reputation: 5427
We are developing a client-server application with Java RMI and, for testing, we will use a computer both as client and as server. So both the client and the server applications must call rmiregistry on the same machine, but they are two different JVMs obviously. How can we do that? We hoped that it was necessary only to give different ports to LocateRegistry but we get NotBoundException... What is the correct way?
Upvotes: 1
Views: 2718
Reputation: 311052
You can run as many as you like, but why? You don't need to. Have the server start its own Registry via LocateRegistry.createRegistry()
, and have the client lookup that one. You seem to think the client needs its own Registry, which isn't correct.
If you got a NotBoundException
clearly either the service wasn't bound at all in any registry, or you looked up the wrong one.
Upvotes: 1
Reputation: 4584
RMI Registry is a server which maintains a registry of services.
So your server should connect to the RMI registry and register itself in it, while client should connect to RMI registry and look up your server
So you need to run a single RMI Registry on your machine.
It seems that you're getting the NotBoundException cause you have two of them
Upvotes: 0