• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why i cannot bind the server in other port

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Recently I try to bind the RMI server with other port rather than 1099, but it fails with: Connection refused to host: 218.244.114.87; nested exception is:
java.net.ConnectException: Connection refused: connect
the code for starting server is like below
try {
java.rmi.registry.LocateRegistry.createRegistry(port);
} catch(RemoteException re) {
Util.log("Create Registry error.");
re.printStackTrace();
}
try {
FBNServer server = new FBNServer(db);
// Bind this object instance to the name "FBNServer"
Naming.rebind("FBNServer", server);
...} catch(IOException e){}
The exception thrown in the second try block.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have another service running on the 'new' port.
If you are using Windows NT/2000/XP then try this command: netstat -a
You should now see all port in use.
Rene
 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks but it still doesn't work.
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/179372/java-developer-SCJD/certification/RMI-Port-Number
That is how I fixed my problem.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


java.rmi.registry.LocateRegistry.createRegistry(port);
FBNServer server = new FBNServer(db);
Naming.rebind("FBNServer", server);


Try this instead, it should work:
java.rmi.registry.LocateRegistry.createRegistry(port);
FBNServer server = new FBNServer(db);
Registry registry = LocateRegistry.getRegistry(port);
registry.rebind("FBNServer", server);
Eugene.
[ January 01, 2003: Message edited by: Eugene Kononov ]
 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much!
I try registry.rebind instead of Naming.rebind and it works.
Question is why?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic