Name: rlT66838 Date: 09/01/99
An attempt to create more than a single registry in the
same VM will fail. Specifically, if
createRegistry(++portNumber) ;
if called more than once, it will throw:
java.rmi.server.ExportException: internal error:
ObjID already in use
I discovered this while trying to implement 2 flavors of
the same rmi service on two different ports: one using
the default socket implementation, one using custom
sockets (ssl, in my case). The object was to service
both ssl-capable and non-ssl-capable clients from the
same vm, all without running an external rmiregistry.
The text of Bug Id 4188333, (a similar, but not identical,
problem) suggests whence the problem arises:
presumably, a single, well-known ObjId is used
for any and all registry instances, hence calling
createRegistry a second time uses this same ObjId for
the new registry instance. The server's export mechanism
doesn't allow this, and throws.
The problem is easily reproducable, as the
following code demonstrates:
---------------------8<-------------------------
import java.rmi.registry.* ;
public class Reg {
public static void main(String [] args)
{ // second createRegistry call fails
try
{ registry1 = LocateRegistry.createRegistry(5555) ;
registry2 = LocateRegistry.createRegistry(6666) ;
}
catch(Throwable t)
{ System.out.println(t) ;
}
}
}
---------------------8<-------------------------
bash-2.02$ java -version
java version "1.2.2"
HotSpot VM (1.0fcs, mixed mode, build E)
bash-2.02$ java -fullversion
java full version "JDK-1.2.2-W"
bash-2.02$
(Review ID: 93916)
======================================================================
Name: skT45625 Date: 08/29/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Creating multiple registries within the same VM causes a
java.rmi.server.ExportException. For example, the following code:
import java.rmi.*;
import java.rmi.registry.*;
public class Foo {
public static void main(String args[]) {
try {
LocateRegistry.createRegistry(12345);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.err.println("registry created on 12345");
try {
LocateRegistry.createRegistry(23456);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.err.println("registry created on 23456");
}
}
when run produces the following output:
registry created on 12345
java.rmi.server.ExportException: internal error: ObjID already in use
at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:164)
at sun.rmi.transport.Transport.exportObject(Transport.java:71)
at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:184
)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:319)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:119)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:12
5)
at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:95)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:81)
at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:1
67)
at lib.Foo.main(Foo.java:17)
This bug was reported as bug id 4120329 previously, and labeled as CLOSED, when
it is clearly not.
(Review ID: 109097)
======================================================================