• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic