File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI and LocateRegistry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI and LocateRegistry" Watch "RMI and LocateRegistry" New topic
Author

RMI and LocateRegistry

Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
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

Joined: Feb 17, 2004
Posts: 58
Try this:



As it is, you create a registry, but don't use it.
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
Yes, that really works ! Thank you very much, Oliver!!!
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
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

Joined: Mar 28, 2003
Posts: 11280
    
  59

Do you have a firewall installed on your computers?

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
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.


42
Denis Zjukow
Ranch Hand

Joined: Mar 15, 2006
Posts: 39
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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI and LocateRegistry
 
Similar Threads
RMI rebind throwing MarshalException
HELP !!!!!
rmi server start
SSLHandshakeException
Exception: Connection refused to host