2 Replies Latest reply on Apr 12, 2005 10:03 PM by Adrian Brock

    DATASOURCE AND JNDI

    Alessandro Salina Newbie

      Ciao,
      sorry if this may be a stupid question... i'm tring to porting an application from iona A.S. to jboss and i 've this problem:

      1) a Session Bean retrive a sqlconnection via jndi
      ...

      Context ctx = ContextFactory.getInitialContextLocal();
      ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MYDB");
      ...

      but in jboss my datasource (i added a new oracle datasource ) is setting as java:/MYDB

      How can i do? is there a way to risolve this without modifing source code?
      Thanks.
      Ale

        • 1. Re: DATASOURCE AND JNDI
          Alessandro Salina Newbie

          if this can help:

          in every definition of ejb in ejb-jar.xml i've put

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

          and the only way i found to solve the problem is to create a jboss.xml like this...

          ...
          ...


          <ejb-name>XXXX</ejb-name>
          <jndi-name>YYYYY</jndi-name>
          <resource-ref>
          <res-ref-name>jdbc/MYDB</res-ref-name>
          <jndi-name>java:/MYDB</jndi-name>
          </resource-ref>

          ...
          ...


          Is there a simpliest solution? i don't want to write a jboss.xml file for every component of my project.....
          is not possible to define in a global way the association jdbc/MYDB --> java:/MYDB ??
          Thanks,
          Ale

          • 2. Re: DATASOURCE AND JNDI
            Adrian Brock Master

            Moderated: Use the EJB forum, although the answer is NO.