• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI and LocateRegistry

 
Denis Zjukow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got a problem with using LocateRegistry. Does anyone has any idea why my code doesn't work:



When I try to run it I got "java.rmi.ConnectException: Connection refused to host: localhost" in the catch clause. The interesting thing is that this code works fine if I run rmiregistry manually (in this case line is not needed and may be commented). But I don't understand why it doesn't work when I try to run the registry programmaticaly. The code of CalkImpl is simple and I don't provide it here because it works fine when using rmiregistry so I suppose that the problem is not in CalkImpl or its stub. Please help. Thank you in advance.
 
Oliver Weikopf
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:



As it is, you create a registry, but don't use it.
 
Denis Zjukow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that really works ! Thank you very much, Oliver!!!
 
Denis Zjukow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody. I got a new problem with RMI.
Everything works greate if I run both server and client on the same computer. But when I try to run it on different machines I got java.rmi.ConnectException. Well network works fine. So I think problem is in something else. I provide my code below:



Method lookup throws the exception. What's wrong? Does anyone know where is the problem. As I said this code works in case of "localhost". But that doesn't make sence as a distributed application must be able to work on different computers. Please help!!!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a firewall installed on your computers?

Regards, Andrew
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
print out the details of the connection on both ends.

Are you hosting the server on Linux? If so check your hosts file and remove any hard mapping of localhost to ip addresses. I had something very similar and that cured it.
 
Denis Zjukow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both Andrew and Jeroen. I run my server on Windows NT. And yes you are right Andrew there is a firewall on the server. It didn't allow access. I just was so confused that didn't noticed the message the firewall showed. I thought I was doing something wrong, you know . But when I allowed the access everything went right. Now my example is really distributed! Thank you!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic