0

I am trying to connect to my localhost when running my application, but for some reason it tries to connect to an ip address other than my localhost.

Below is the error message I am getting. error

I have looked at my hosts file and is mapped like below:

hostsfile

ctrak93
  • 49
  • 9

1 Answers1

0

As you are manually creating the Registry you could change the line 14 and 17 to

Registry registry = LocateRegistry.createRegistry(1099);

registry.bind("fileService", fs);

On the other hand Naming.rebind suppose to default the host to localhost but you could specify it anyway

Naming.rebind("//localhost/fileService", fs)

thought in that case the line with LocateRegistry.createRegistry is not necessary

Edwin
  • 836
  • 7
  • 17
  • https://stackoverflow.com/questions/3630329/difference-between-classes-java-rmi-registry-registry-and-java-rmi-naming it gives some detail on these alternatives – Edwin Oct 19 '18 at 10:50
  • great that worked thank you. Any idea as to why the first method wasn't working as I was following my lecturers notes and that above main method worked for other people in my class – ctrak93 Oct 19 '18 at 11:28
  • honestly not sure, in your code i think it was not necessary the `LocateRegistry.createRegistry(1099);`, maybe that was causing some conflict, it could also be that in some version of java `Naming,rebind` doesn't have the default host as localhost – Edwin Oct 19 '18 at 18:36