• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

rmi connection refused if not 1099

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe somebody else meets this too, but I couldn't find related post.
To start rmi server programatically, I use LocateRegistry.createRegistry(portNum);
my code:
LocateRegistry.createRegistry(1099);
Hello h = new Hello("Steve");
Naming.rebind("TEST",h);
Everything works successfully for 1099(including client calling the method), however, if the port is not 1099, let's say 1098, the following exception occures at Naming.rebind.
I am using java version 1.4.2_01. Thank you for the advice!!
Exception in thread "main" java.rmi.ConnectException: Connection refused to hos
: 10.40.194.54; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at Test.main(Test.java:13)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown
ource)
... 7 more
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YungSheng,
The code you show creates a new registry but uses the default registry, not the new one.
After creating the registry, you have to get a reference to it and then use it to perform the binding as in the following example:
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The createRegistry() method does have a return value, for precisely this purpose:
 
YungSheng Chang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it works, thank you all.
In fact, we were taught to use network socket to write project in school. That may be quite different from you guys. Well I have to say RMI is more straightforward though.
Yap, if you ever implement the "network whiteboard" project, we may go to the same school.
 
this is supposed to be a surprise, but it smells like a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic