9 Replies Latest reply: Feb 1, 2011 6:58 AM by 819650 RSS

    new InitialContext() hangs up...help please


      I met a problem like the function "InitialContext()" hung up for many days...I'm using the Java ORB for RMI-IIOP communications.
      The JDK version looks like,
      java version "1.6.0_21"
      Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
      Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)

      My source looks like,

      ORB orb = ORB.init((String[])null, properties);
      Hashtable environment = new Hashtable();
      environment.put("java.naming.provider.url", "iiop://" + hostname + ":"
      + portId);
      environment.put("java.naming.corba.orb", orb);
      // Setup naming context
      namingContext = new InitialContext(environment); -----> hung up here

      The orb properties look like,
      /opt/cems/jre/bin/orbd -ORBInitialPort 1050 -ORBServerHost -defaultdb /opt/cems/adm/orb.db -Dcom.sun.CORBA.connection.ORBHighWaterMark=4050 -Dcom.sun.CORBA.connection.ORBLowWaterMark=4000 -J-Xmx256m

      The thread dump looks like,

      "Thread-9" daemon prio=3 tid=0x0032bc00 nid=0x1c in Object.wait() [0xb637e000]
      java.lang.Thread.State: WAITING (on object monitor)
           at java.lang.Object.wait(Native Method)
           - waiting on <0xe760a370> (a java.lang.Object)
           at java.lang.Object.wait(Object.java:485)
           at com.sun.corba.se.impl.transport.CorbaResponseWaitingRoomImpl.waitForResponse(CorbaResponseWaitingRoomImpl.java:140)
           - locked <0xe760a370> (a java.lang.Object)
           at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.waitForResponse(SocketOrChannelConnectionImpl.java:1084)
           at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.waitForResponse(CorbaMessageMediatorImpl.java:253)
           at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete1(CorbaClientRequestDispatcherImpl.java:362)
           at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:336)
           at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:129)
           at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:213)
           at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
           at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
           at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:404)
           at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:298)
           at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:264)
           at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:232)
           at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:87)
           at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:32)
           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)
           at com.NTX.cdma.gsf.util.NamingServerUtilities.getNamingContext(NamingServerUtilities.java:122)
           at com.NTX.cdma.gsf.process.ProcessWatchdog.waitForNamingServer(ProcessWatchdog.java:3669)
           at com.NTX.cdma.gsf.process.NamingServerThread.run(NamingServerThread.java:273)
           - locked <0xe760a2e0> (a com.NTX.cdma.gsf.process.NamingServerThread)

      Would anyone give me some suggestions?


      Edited by: Arica on Jan 29, 2011 5:49 PM

      Edited by: Arica on Jan 29, 2011 5:50 PM
        • 1. Re: new InitialContext() hangs up...help please
          I checked the JDK internal class CorbaResponseWaitingRoomImpl, and the call was hanging at following block of function waitForResponse()

          synchronized(call.done) {

          while (call.inputObject == null && call.exception == null) {
          // Wait for the reply from the server.
          // The ReaderThread reads in the reply IIOP message
          // and signals us.
          try {
                    if (orb.transportDebugFlag) {
                         dprint(".waitForResponse: waiting: "
                         + opAndId(messageMediator));
          call.done.wait(); ----> hanging...

          The notify() function was called at responseReceived() like,

          synchronized (call.done) {
               CorbaMessageMediator messageMediator = (CorbaMessageMediator)

               if (orb.transportDebugFlag) {
                    dprint(".responseReceived: "
                    + opAndId(messageMediator)
                    + ": notifying waiters");

          call.inputObject = is;

          It seems that the JAVA ORB won't response the request sometimes.
          • 2. Re: new InitialContext() hangs up...help please
            Are you sure you're connecting to the right port for the COSNaming service? and do you have the orbd running?
            • 3. Re: new InitialContext() hangs up...help please
              Yes. I'm sure the orbd is running, the command
              /usr/ucb/ps -auxwww <orbd pid> will show,

              /opt/cems/jre/bin/orbd -ORBInitialPort 1050 -ORBServerHost -defaultdb /opt/cems/adm/orb.db -Dcom.sun.CORBA.connection.ORBHighWaterMark=4050 -Dcom.sun.CORBA.connection.ORBLowWaterMark=4000 -J-Xmx256m

              I tried another mini JAVA application to connect to the ORB and just iterated all references bound into the ORB, that application run well.

              I never met the issue before, but recently, after we upgraded the JDK from 1.6.0_16 to 1.6.0_21, the issue can be reproduced intermittently.
              • 4. Re: new InitialContext() hangs up...help please
                the issue can be reproduced intermittently.
                Ah. You didn't say it was intermittent. That suggests network problems to me. There are read timeout properties you can set, I would suggest you do that.
                • 5. Re: new InitialContext() hangs up...help please
                  many thanks for your help.

                  But...the hang kept more than 2 days...if the issue was aroused by network problems, I think that I should get a timeout message at least within the 2 days, shouldn't I?

                  BTW, I tried to write a testing code to connect to the orbd locally to iterate all bound references when my application hung up, the testing code worked fine and can connect to the orbd.
                  • 6. Re: new InitialContext() hangs up...help please
                    If you don't set a timeout there is no timeout. That's why I suggested setting a timeout. Without a timeout you can wait forever.
                    • 7. Re: new InitialContext() hangs up...help please
                      ah...that's probably the root cause.

                      Would you please tell me how to set the timeout to request the orbd? In particular when I create the InitialContext?
                      • 8. Re: new InitialContext() hangs up...help please
                        Sorry, it depends on the ORB vendor, or the JDK version if you're using the built-in one. I did a table of JDK ORB properties a couple of years ago but it could be entirely out of date by now. Had to read the JDK source for it.
                        • 9. Re: new InitialContext() hangs up...help please
                          OK, understood.

                          Appreciate to your timely help very much.