2 Replies Latest reply on Sep 28, 2001 7:11 AM by neil blue

    problem using relative JNDI names

    neil blue Newbie

      Hello,

      I am using a simple session bean to access a JNDI datasource.

      The ejb-jar file contains:
      <resource-ref>
      The MySQL DS
      <res-ref-name>jdbc/MySQL</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      The jboss.xml contains:
      <resource-ref>
      <res-ref-name>jdbc/MySQL</res-ref-name>
      <jndi-name>java:/MySQL</jndi-name>
      </resource-ref>

      From the session bean, the following code works
      ...
      InitialContext ic = new InitialContext();
      DataSourceds=(DataSource)ic.lookup("java:comp/env/jdbc/MySQL");
      Connection con = ds.getConnection();
      ...

      but this code does not:
      ...
      InitialContext ic = new InitialContext();
      DataSource ds = ( DataSource ) ic.lookup("jdbc/MySQL");

      however the documentation seems to imply that this will work.Could anyone tell me why this is not the case please.

      Cheers
      Neil