1 Reply Latest reply on Jul 11, 2008 2:23 AM by jaikiran pai

    Datasource Lookup Problem

    Adrian layne Newbie

      I am trying to deploy an application that has predefined datasource names

      I added a jboss-web.xml to the web-inf folder with these contents

      <jboss-web>
      <resource-ref>
      <res-ref-name>jdbc/blah</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:blah</jndi-name>
      </resource-ref>
      </jboss-web>

      The web.xml has the following resource ref

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

      <%
      javax.naming.InitialContext ctxt = new javax.naming.InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource) ctxt.lookup("jdbc/blah");
      java.sql.Connection conn = ds.getConnection();
      %>
      <%=conn%>
      <%conn.close();%>

      when i run the app i get the following exception

      javax.servlet.ServletException: javax.naming.NameNotFoundException: jdbc not bound

      if i change the look up from ctxt.lookup("jdbc/blah"); to ctxt.lookup("java:jdbc/blah"); it works.