|
Description
|
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 customer 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. customer $ java -version
java version "1.2.2"
HotSpot VM (1.0fcs, mixed mode, build E)
bash-2. customer $ java -fullversion
java full version "JDK-1.2.2-W"
bash-2. customer $
(Review ID: 93916)
======================================================================
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. customer .TCPTransport.exportObject(TCPTransport.java:184
)
at sun.rmi.transport. customer .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)
======================================================================
|
|
Comments
|
Submitted On 21-MAY-2000
abcoates
Note: this problem appears to make it impossible to create an RMI registry on port 1099 from within a
servlet running under Tomcat.
Submitted On 14-DEC-2000
ptasillo2
Still broken in jdk113!
Submitted On 04-JAN-2002
raimondas
the same in jdk1.3.1
Submitted On 06-MAR-2002
wenyi6
The same behavior in jdk1.4.0.b92
Submitted On 24-APR-2002
ElementMaster
Same in 1.4 jdk using servlet version 1.2.
Quite frustrating :)
Submitted On 13-MAR-2003
darekrutk
the same in jdk1.4.1
Submitted On 08-APR-2003
summeray
Same in jdk 1.4.1_02-b06
Submitted On 12-DEC-2003
brianwhitney
I am still seeing this issue in 1.4.2_01! Does anyone
know when this might be fixed????!!!!!
Submitted On 14-APR-2004
rambarrambar
I am still suffering this bug at 1.4.2
Submitted On 09-MAR-2005
ben-the-unix
also having same problem with 1.4.2
Submitted On 09-FEB-2006
This is fixed in JDK1.5. The real question is whether it wil be backported to the 1.4 series?
Submitted On 28-FEB-2006
Jammy@Java
This certainly isn't fixed in 1.5! At least not for Mac OSX.
Submitted On 26-JUN-2007
ejp
Works in 1.5 for me on Windows ...
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|