1 Reply Latest reply on Sep 27, 2006 1:19 AM by visolvejboss

    Configuring a datasource for web application

    jgalzic

      I'm a little confused on how I can get a datasource hooked up via JNDI for my web application. I'm used to working on Tomcat and to configure the JNDI, it was a matter of dropping an xml file into the server's conf directory but I'm having a difficult time getting my app to work inside JBoss.

      I have my web.xml that refers to the JNDI resource name as such:

      <resource-ref>

      Resource reference to a factory for java.sql.Connection
      instances that may be used for talking to a particular
      database that is configured in the server.xml file.

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


      I also have a jboss-web.xml which contains:

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


      However, when Jboss starts up and loads my war file, it tells me that:
      org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: resource-ref: jdbc/myDatabase has no valid JNDI binding. Check the jboss-web/resource-ref.)

      Is there some other file I need to configure?Can someone tell me what needs to be done to associate my datasource via JNDI?

      Thanks
      Justin