United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4267864 Can't run create multiple registries in same vm.
4267864 : Can't run create multiple registries in same vm.

Details
Type:
Enhancement
Submit Date:
1999-09-01
Status:
Resolved
Updated Date:
2003-09-18
Project Name:
JDK
Resolved Date:
2003-09-18
Component:
core-libs
OS:
solaris_2.5,generic,windows_2000
Sub-Component:
java.rmi
CPU:
x86,sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.2,1.3.0
Fixed Versions:
5.0

Related Reports
Duplicate:

Sub Tasks

Description

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)
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b21


                                     
2004-06-14
WORK AROUND



Name: rlT66838			Date: 09/01/99


None, other than running registries in seperate
VMs.  This works "around" the bug, but incurs 
the extra cycles/management overhead of extra
processe(s).
======================================================================
                                     
2004-06-11
EVALUATION

This will be fixed when we have an object table per exported endpoint (probably
in the Merlin release).
ann.wollrath@East 1999-09-02

It is possible with the new APIs in merlin to create multiple registries in
the same VM, so I am marking this RFE as fixed/integrated in merlin.
ann.wollrath@East 2001-01-10

Because JSR-78 has not been approved:

	http://java.sun.com/aboutJava/communityprocess/jsr/jsr_078_rmicrr.html

this RFE will not be satisfied as described above for the Merlin release.
peter.jones@East 2001-02-22

This bug is under consideration for Tiger.
###@###.### 2003-07-10

The internal object table is now keyed on a combination of ObjID and Transport
so that multiple registries (each on a different port) can be exported.
###@###.### 2003-09-17
                                     
2003-09-17



Hardware and Software, Engineered to Work Together