3 Replies Latest reply on Dec 8, 2004 10:46 PM by Joan Horta Tosas

    jndi's error

    Jin Di Newbie


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

      <?xml version="1.0"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"

      there is nothing in web.xml and jboss-web.xml

      but when i

      how do the program will correctly?

        • 1. Re: jndi's error
          Darran Lofthouse Master

          Use JNDI View in jmx-console to see what is actually bound.

          • 2. Re: jndi's error
            chuck hutchinson Newbie


            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:


            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!):


            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.

            • 3. Re: jndi's error
              Joan Horta  Tosas Novice

              Where are you trying to access the EJBs? In the web tier? If so, you must define the reference in web.xml and jboss-web.xml files.