4 Replies Latest reply on Feb 26, 2004 7:22 PM by nimrod

    Why can not find DataSource by running java file in command

    nimrod Newbie

      The Jboss 3.2 (with Tomacat 4.1 integrated) server is running and the myDS bound to the DataSource correctly.

      I can find the DataSource by the JNDI name myDS in JSP files which also have been deployed to the server in default folder ROOT.war.

      But I writed a Java file to access myDS, I complied it to Class file and then I run it in command line, it displayed :

      javax.naming.NameNotFoundException: myDS not bound......

      Here is the code for the Java file:
      .
      .
      .
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      Context ctx = new InitialContext(p);
      ds = (DataSource) ctx.lookup("java:/myDS");
      .
      .
      .

      Thanks for any help that anyone can provide.