Hi,
I am VERY close to being finished with the assignment, I just have a slight problem with RMI...
My design is as follows: I use the "wrapper" design
pattern. I have a ContractorServer interface, which the GUI always works against obviously.
The interface has one direct implementations: a LocalServer which handles all real communication with the Data class (backend). The ContractorServer then has an interface RMIServerInterface which extends ContractorServer, Remote. Finally I have RMI server implmentation called RMIServer which extends UnicastRemoteObject and obviously also implements the RMIServerInterface. The RMIServer wraps a local server and delegates all calls to it.
The server is created like so:
And
I THOUGHT this would mean that when the GUI called for instance the "find" method on the ContractorServer object, the object would be a ContractorServer interface stub, the stub would call back to the real RMIServer living on the server JVM, the RMIServer would call the LocalServer it is wrapping and all would work.
Connecting to the remote server works fine and I get a stub. But then when I try to call the "find" method, it seems the stub is trying to connect to "localhost", NOT back to the original server it came from. Running both client and server in two different JVMs on the same computer works, but not on two different since the stub (I think) keeps trying to contact only localhost.
The "find" method in RMIServer looks like this:
What am I doing wrong?