• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI registry is running?

 
Alexander V Fahrmann
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

registry = LocateRegistry.createRegistry(portNumber);


could cause
java.rmi.server.ExportException: internal error: ObjID already in use
being thrown provided that the Registry instance on the local host that accepts requests on the specified port has been created already.

So, the question is: how to avoid the issue? Because according to the
API documentation:
"getRegistry call does not actually make a connection to the remote host. It simply creates a local reference to the remote registry and will succeed even if no registry is running on the remote host."

That is, if the registry is running already the getRegistry method
returns what you want, otherwise - you will get a RemoteException for sure.

P.S.: the java.rmi.server.ExportException could be thrown for another reasons also, I belive, so catching this exception does not garantee that
it was thrown because the registry is running already..

P.P.S.: I do not relish solutions of the sort: "Just make sure (by implementation) the code: LocateRegistry.createRegistry(portNumber) does
not invoked twice (with the same argument)".
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I question, however, why would you try to invoke the getRegistry method after an unsuccessfull createRegistry invocation?
 
Alexander V Fahrmann
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not going to invoke getRegistry method - maybe, I will not use it even.

The question is: how to determine is the registry running?
[ April 10, 2008: Message edited by: Alexander V Fahrmann ]
 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good question. Not handling the state of the rmi registry
properly can prevent the server from starting if another java application
is using the rmi registry at the time the server attempts to start.
(By the way, this problem exists on the Monkhouse&Camerlengo program).

I have not found a correct way to deal with it for the moment, but the following thread could help :
http://forum.java.sun.com/thread.jspa?threadID=5242976&messageID=10000368

Gilles
 
Alexander V Fahrmann
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, for your reply, Gilles.

Time goes by... but I still do not see a workaround for the issue.
Maybe, I will just allow the Exception to propagate up to the GUI level
and force the user to try to start the server again suggesting that,
perhaps, he/she should use another port...
[ April 11, 2008: Message edited by: Alexander V Fahrmann ]
 
tetsu soh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Edwin Dalorzo.

There are two possibility:
1. There is another rmi registry in your JVM. It seems impossible unless you try to create it twice.

2. The port is used by another process. Whatever that process is, you should stop your application. Even that process is a rmi registry, your application should not try to use it because SUN told us MUST NOT use Dynamic code downloading and you cannot pre-install your class to the unknown rim registry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic