1. glassfish
  2. GLASSFISH-18984

[PERF] SerialInitContextFactory doesn't find ORB when using multiple threads


    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 4.0_b48
    • Fix Version/s: None
    • Component/s: naming
    • Labels:


      For load generation, we have a client that spawns multiple threads, each of which gets an InitialContext. Periodically, this operations fails to connect to the glassfish ORB:

      java.lang.RuntimeException: Could not get ORB
      at com.sun.enterprise.naming.impl.SerialInitContextFactory.getORB(
      at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(
      at javax.naming.spi.NamingManager.getInitialContext(
      at javax.naming.InitialContext.getDefaultInitCtx(
      at javax.naming.InitialContext.init(
      at javax.naming.InitialContext.<init>(

      I adding some debugging statements to the SerialInitContextFactory. The basic process of that code is:

      Habitat temp = defaultServices;
      if (temp == null)

      { temp = Globals.getDefaultHabitat() ; }

      if (temp == null)

      { // May need to initialize hk2 component model in standalone client temp = Globals.getStaticHabitat() ; }

      if (temp != null) {
      ORBLocator orbLocator = temp.getService(ORBLocator.class) ;
      if (orbLocator != null)

      { return orbLocator.getORB() ; }

      throw new RuntimeException( "Could not get ORB" ) ;

      When a single thread executes this, everything is fine: the habitat is initialized via the getStaticHabitat call and the getService call returns a locator which then gets the ORB.

      When multiple threads execute this, some of them fail: for some of the threads, the call to getService returns null. Eventually, the call to getService will start returning the locator and for those threads, everything is fine. But for the threads that get there too soon, getService returns null. That would seem to indicate that the habitat which is returned from the getStaticHabitat() call is not fully initialized yet.

      This all worked prior to the HK2 integration and the SerialInitContextFactory code has not substantially changed here (other than the API calls) into HK2, so I'm assigning it to HK2. I would guess that the issues is in Globals.getStaticHabitat() when it returns the previouslyCreated habitat from locator.getService().


        There are no comments yet on this issue.


          • Assignee:
            Scott Oaks
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: