Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9365

InitialContext#lookup does not timeout on cached context


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:


      I've got an issue where InitialContext#lookup will hang forever doing a lookup if there is a problem with the network. I appreciate this is the default settings of the TCP sockets to wait forever, so I've tried to configure the timeout using 'jnp.timeout' and 'jnp.sotimeout'. If the network is disconnected prior to the first attempt to do a lookup it times out as expected (I assume this is 'jnp.timeout' which configures the timeout to create the connection). However, if the network is disconnected after one ore more successful lookups have been performed it waits forever. I assume this is there 'jnp.sotimeout' should have kicked in, but doesn't seem to.

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.provider.url", "jnp://");
      env.put("java.naming.factory.url.pkgs", "org.jboss.naming");
      env.put("jnp.socketFactor", "org.jnp.interfaces.TimedSocketFactory");
      env.put("jnp.timeout", "1000");
      env.put("jnp.sotimeout", "1000");
      InitialContext ctx = new InitialContext(env);
      // disconnect network here

      In the above example if I disconnect the network before the first lookup it times out as expected, but if I disconnect the network between the first lookup and the second lookup it waits forever. I've tried to wrap it in a thread, that is then interrupted after a timeout, but that doesn't work.

      Looking at the source code from JBoss Naming it seems that 'jnp.timeout' and 'jnp.sotimeout' is only used to retrieve the NamingServer_Stub, once that is retrieved and cached I can't see that they are being used any longer. I believe this would result in the problem I'm seeing as NamingServer_Stub#lookup would not have a socket timeout associated with the RMI call.

        Gliffy Diagrams


          stianst Stian Thorgersen added a comment -

          Also created JBNAME-53, but wasn't sure where I should post this bug

          stianst Stian Thorgersen added a comment - Also created JBNAME-53 , but wasn't sure where I should post this bug


            • Assignee:
              stianst Stian Thorgersen
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: