1 Reply Latest reply on Feb 14, 2003 10:51 AM by David Swift

    InitialContext.lookup Hangs

    David Swift Newbie

      I have a code fragment (shown below) that worked last week. The only thing that's changed in my environment since then is that the Linux box running jboss-3.0.4 is now getting its IP address via DHCP. The program hangs at the jndiContext.lookup() call at the end. The log files don't seem to indicate any problems. I got a few warnings about missing jar files that according to a search on the forum, appear not to be a problem. I tried browsing the IP address and port, but I got nothing from that. Is there any definite way to know that the JNDI service is actually up and running?

      public static void main(String[] args) {
      String queueName = null;
      Context jndiContext = null;
      QueueConnectionFactory queueConnectionFactory = null;
      QueueConnection queueConnection = null;
      QueueSession queueSession = null;
      Queue queue = null;
      QueueReceiver queueReceiver = null;
      TextMessage message = null;

      queueName = "queue/testQueue";

      * Create a JNDI API InitialContext object if none exists
      * yet.
      System.out.println("About to get a context.");
      try {
      jndiContext = new InitialContext();
      } catch (NamingException e) {
      System.out.println("Could not create JNDI API " +
      "context: " + e.toString());

      System.out.println("About to get a queue connection factory.");
      try {
      queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory");

        • 1. Re: InitialContext.lookup Hangs
          David Swift Newbie

          Please disregard my initial posting. We found the problem. A colleague of mine figured out that moving the box to another part of the network was the root cause. He speculated that the RMI portion of the server was relying on the getHostName (not sure about case of above call) command and while that's a reasonable thing to do, it doesn't work if a machine is moved to a different part of the network.