4 Replies Latest reply on Oct 6, 2001 9:45 PM by davidjencks

    Unable to Lookup DataSource

    s.suresh

      I am using JBoss 2.4. I was able to register my SQL JDBC Driver in the jboss.jcml file. During startup it displays the following

      [SQLServerPool] XA Connection pool SQLServerPool bound to java:/SQLServerPool

      But when I use the following code to lookup for the same

      Hashtable ht = new Hashtable();
      ht.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      ht.put(Context.PROVIDER_URL, "localhost:1099");
      ht.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces");

      ctx = new InitialContext(ht);

      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("java:/SQLServerPool");

      I get the following error

      javax.naming.NameNotFoundException: SQLServerPool not bound


        • 1. Re: Unable to Lookup DataSource
          p_d_austin

          Where are you making the call from, if you are in a separate VM the datasource will not be available as it is only bound in the local JNDI registry on the server.

          • 2. Re: Unable to Lookup DataSource
            s.suresh

            Hi Austin,

            Thank you very much. I was making the connection from a program which was in different JVM. Then I used the same code in a servlet and deployed it in TOMCAT and it worked. (TOMCAT and JBoss in same JVM)

            Thanks once again

            • 3. Re: Unable to Lookup DataSource

              Hi. I would appreciate it if anyone can answer the
              following questions:

              1. Is there a way to access the data source from a
              separate VM?

              2. Why is it that I can access an EJB from another VM,
              but I can't access a data source?

              Thanks.

              Jason

              • 4. Re: Unable to Lookup DataSource
                davidjencks

                1. no

                2. The ejb stuff is specifically designed for remote access through rmi (or possibly other means, but definitely remote access): thats more or less the purpose of the container, home and remote interfaces, etc. Despite Webligics wrapping connection factories in remotable DataSources, database connections are not designed to be remotable, and if you think about it, its not a very good idea (IMHO): from a purely practical standpoint you are adding an extra hop between vms in an already very slow process, and from an architectural standpoint you are mixing logical layers in your app.