0 Replies Latest reply on Jul 3, 2002 11:42 AM by Eduardo Piovesam

    Not bound problem... (I know, it must be in the same VM, but

    Eduardo Piovesam Newbie

      Hello all,

      Ok, I saw in many threads here that to do a ctx.lookup("java:/DefaultDS") the application must be in the same VM as JBoss.

      But just to clarify to me: it's in the same JVM or "in the JBoss app server as an EJB"? Sorry, but I'm new to JBoss.

      Because I'm building a new application to run in the same JVM as JBoss, and it's giving the "not bound" exception. It's not an EJB, it's a simple app which just try to connect to the "DefaultDS" DataSource:

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

      public class DSTest
      {
      public static void main(String[] args)
      {
      try
      {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "localhost:1099");
      env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

      Context ctx = new InitialContext(env);
      DataSource ds = null;

      try {
      ds = (DataSource) ctx.lookup("java:/DefaultDS");
      System.out.println("bound!!!!");
      }
      catch (Exception e) { e.printStackTrace(); }

      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }
      }

      And then, it gives:
      javax.naming.NameNotFoundException: "DefaultDS" not bound


      I've tried with "java:DefaultDS", "java:/DefaultDS", "DefaultDS", ... everything...

      And I can see the "DefaultDS" in the JNDIView in http://server:8082..

      Any clue?

      Thank you!
      Eduardo