kill rmi server, but Naming.list still works

Hi,

i have built an rmi server program, which creates some remote objects and a program which lists them. However, the program still lists the objects after the server has shudown. Only as soon as i kill the rmiregistry, the listing stops. Why?

import java.rmi.*;

import java.rmi.server.*;

/**

This server program instantiates two remote objects,

registers them with the naming service, and waits for

clients to invoke methods on the remote objects.

*/

publicclass ProductServer2

{

publicstaticvoid main(String args[])

{

try

{

System.out.println

("Constructing server implementations...");

ProductImpl p1

=new ProductImpl("Blackwell Toaster");

ProductImpl p2

=new ProductImpl("ZapXpress Microwave Oven");

System.out.println

("Binding server implementations to registry...");

Naming.rebind("toaster2", p1);

Naming.rebind("microwave2", p2);

System.out.println

("Waiting for invocations from clients...");

}

catch(Exception e)

{

e.printStackTrace();

}

}

}

The following program lists the remote objects:

import java.rmi.*;

import java.rmi.server.*;

publicclass ShowBindings

{

publicstaticvoid main(String[] args)

{

try

{

String[] bindings= Naming.list("");

for (int i=0; i<bindings.length; i++)

System.out.println(bindings[i]);

}

catch(Exception e)

{

e.printStackTrace();

}

}

>

[2966 byte] By [uiga] at [2007-10-2 16:15:31]
# 1

The RMI Registry holds references to remote objects. Your "list" goes against the Registry, not the remote objects.

The Registry doesn't care what remote objects are alive or dead. That's not it's purpose.

Use unbind() to remove references in the Registry before ending your server.

cooper6a at 2007-7-13 17:05:17 > top of Java-index,Core,Core APIs...