3 Replies Latest reply on Mar 12, 2003 9:37 AM by jimvoris

    ConnectionFactory lookup

    itaimaoz

      Hi,

      I have a client application that looks up the ConnectionFactory. When the servers is shut down and then restart the lookup fails untill my client is erstarted too.

      Here is a simulated behavior:

      package jboss.client;

      import javax.naming.*;
      import java.util.Properties;

      public class TestJNDIReconnect {
      static String str = "ConnectionFactory";
      public static void main(String[] args) {
      while (true) {
      try {
      Properties props = new Properties();

      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      InitialContext ctx1 = new InitialContext(props);

      Object ref1 = ctx1.lookup(str);

      System.out.println(ref1);

      } catch (Exception ex) {
      System.err.println(ex.getMessage());
      }

      try {
      Thread.sleep(5*1000);
      } catch (InterruptedException iex) {}

      }
      }
      }

      The output is:
      org.jboss.mq.SpyConnectionFactory@7ee8b8
      org.jboss.mq.SpyConnectionFactory@195d80
      org.jboss.mq.SpyConnectionFactory@341960
      <!-- server went down -->
      ConnectionFactory not bound
      ConnectionFactory not bound
      null
      null
      null
      <!-- server went up-->
      null
      null
      null
      null


      Thanks,
      Itai