How to unexport or shut down programmatically created rmi registry?

M

m

Hello,

I want to start and shut down the rmi registry programmatically.

To start a registry is very easy:

LocateRegistry.createRegistry(1099);

I thought stoping is easy, too:

Registry registry = LocateRegistry.getRegistry(1099);
UnicastRemoteObject.unexportObject(registry, true);

But the method unexportObject(...) throws an exception:

java.rmi.NoSuchObjectException: object not exported
at
sun.rmi.transport.ObjectTable.unexportObject(ObjectTable.java:135)
at
java.rmi.server.UnicastRemoteObject.unexportObject(UnicastRemoteObject.java:231)

Does anybody know how to shut down the programmatically created
registry?

Regards,
Martin
 
E

Esmond Pitt

Hello,

I want to start and shut down the rmi registry programmatically.

To start a registry is very easy:

LocateRegistry.createRegistry(1099);

This will work:

Registry reg = LocateRegistry.createRegistry(1099);
// ...
UnicastRemoteObject.unexportObject(reg,true);

the reason being that LocateRegistry.createRegistry returns the Registry
object itself, not a stub.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top