• Post Reply Bookmark Topic Watch Topic
  • New Topic

why i cannot bind the server in other port  RSS feed

 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks but it still doesn't work.
 
John Lee
Ranch Hand
Posts: 2545
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks very much!
I try registry.rebind instead of Naming.rebind and it works.
Question is why?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!