2 Replies Latest reply on Dec 8, 2004 11:02 PM by chuck hutchinson

    jndi/datasource error similar to jndi/ejb post by codemyth

    chuck hutchinson Newbie

      Hi

      I am new to jboss and and looking through the posts to find my problem with JNDI which looks very similar to the one that codemyth has. Mine though is with a simple data source using jboss 3.2.6. Codemyth's problem was related to jndi-ejb lookups.

      Here is my source:

      part of web.x.xml where my datasource is defined:

      <resource-ref>
      blah
      <res-ref-name>jdbc/honeypot</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      part of jboss-web.xml where a different resource-ref is defined for jboss (I don't know WHY I need this but I found it on a different forum saying that I would need to define it here - so I did and here it is!):

      <resource-ref>
      <res-ref-name>jdbc/honeypot</res-ref-name>
      <jndi-name>jdbc/honeypot</jndi-name>
      </resource-ref>


      Next is my snippet of code that looks up the resource:

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

      initCtx = new InitialContext(props);

      listContext (initCtx);
      log.info ("Getting honeypot datasource!");

      dataSource = (DataSource)initCtx.lookup ("java:comp/env/jdbc/honeypot");

      log.info ("Getting Connection!");

      Now part of the exception trace that I am getting:
      2004-12-08 16:04:38,221 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]
      2004-12-08 16:04:38,231 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:972)
      2004-12-08 16:04:38,231 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:615)
      ...
      ...
      ...

      Now I can print out the JNDI tree under "java:comp/env/jdbc" and I do see the "honeypot" entry. But when I look it up this is where I get the exception.