facebook

[Closed]jndi reference problem(urgent)?

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #263476 Reply

    augustfox
    Member

    My environment is myeclipse4.1.1+jboss4.0.1sp1+DB28.2.
    When I wanna get a database connection,i meet with a problem,the error as follows:
    14:38:06,343 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]
    14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:999)
    14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
    14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:658)
    14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
    14:38:06,343 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialContext.java:347)

    My code like this:
    Context context = new InitialContext();
    return (DataSource) context.lookup(“java:comp/env/jdbc/test”);

    I can get connecton via context.lookup(“java:jdbc/test”),
    but i still want to know why context.lookup(“java:comp/env/jdbc/test”) not works?
    I want to get your help eagerly!

    my db2-ds.xml:
    <local-tx-datasource>
    <jndi-name>jdbc/test</jndi-name>
    <connection-url>jdbc:db2:tempdb</connection-url>
    <driver-class>COM.ibm.db2.jdbc.app.DB2Driver</driver-class>
    <user-name>test</user-name>
    <password>test</password>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>20</max-pool-size>

    <metadata>
    <type-mapping>DB2</type-mapping>
    </metadata>
    </local-tx-datasource>

    my web.xml:
    <resource-ref>
    <res-ref-name>jdbc/test</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

    my jboss-web.xml:
    <resource-ref>
    <res-ref-name>jdbc/test</res-ref-name>
    <jndi-name>jdbc/test</jndi-name>
    </resource-ref>

    I also tried resource-env-ref in my web.xml and jboss-web.xml,it still not works.

    #263594 Reply

    augustfox
    Member

    The problem has solved as follows:

    change jboss-web.xml:
    <resource-ref>
    <res-ref-name>jdbc/test</res-ref-name>
    <jndi-name>java:jdbc/test</jndi-name>
    </resource-ref>

    #263612 Reply

    Greg
    Member

    Glad you got it working.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: [Closed]jndi reference problem(urgent)?

You must be logged in to post in the forum log in