glassfish
  1. glassfish
  2. GLASSFISH-18984

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

    Details

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

      Description

      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(SerialInitContextFactory.java:156)
      at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:180)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      ...

      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().

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated: