4 Replies Latest reply on Sep 6, 2008 3:41 AM by braca

    JNDI lookup of DataSource failed

    braca

      Hello,

      I can't get connected to my Oracle-DB with my Web Application (war). JBoss 4.2.3 is connected to Oracle (relevant tables have been deployed). However, no connection is possible through my web app. The exception is as follows:

      21:11:42,847 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
      21:11:42,991 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=OracleDS' to JNDI name 'java:OracleDS'
      21:11:43,995 INFO [A] Bound to JNDI name: queue/A
      21:11:43,999 INFO [B] Bound to JNDI name: queue/B
      21:11:44,003 INFO [C] Bound to JNDI name: queue/C
      21:11:44,007 INFO [D] Bound to JNDI name: queue/D
      21:11:44,012 INFO [ex] Bound to JNDI name: queue/ex
      21:11:44,044 INFO [testTopic] Bound to JNDI name: topic/testTopic
      21:11:44,049 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
      21:11:44,053 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
      21:11:44,058 INFO [testQueue] Bound to JNDI name: queue/testQueue
      21:11:44,109 INFO [UILServerILService] JBossMQ UIL service available at : /127.0.0.1:8093
      21:11:44,164 INFO [DLQ] Bound to JNDI name: queue/DLQ
      21:11:44,194 INFO [TomcatDeployer] deploy, ctxPath=/FinanzManagerKUR, warUrl=.../tmp/deploy/tmp17011FinanzManagerKUR-exp.war/
      21:11:44,205 WARN [ServiceController] Problem starting service jboss.web.deployment:war=FinanzManagerKUR.war,id=1936763747
      org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: resource-ref: OracleDS has no valid JNDI binding. Check the jboss-web/resource-ref.)
      at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:384)
      at org.jboss.web.WebModule.startModule(WebModule.java:83)
      at org.jboss.web.WebModule.startService(WebModule.java:61)

      I use only a web.xml for my web-app:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>FinanzManagerKUR</display-name>
      <welcome-file-list>
      <welcome-file>index.jspx</welcome-file>
      </welcome-file-list>
      <resource-ref>
      JNDI DataSource for OracleDS database im JBoss
      <res-ref-name>OracleDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </web-app>

      Do I need anything else? Config/Xml-Files, or libs? But it seems the JNDI-Binding is wrong... Can anyone help me?
      Thanks, braca

        • 1. Re: JNDI lookup of DataSource failed
          peterj

          Add a WEB-INF/jboss-web.xml file with these contents:

          <jboss-web>
           <resource-ref>
           <res-ref-name>OracleDS</res-ref-name>
           <jndi-name>java:OracleDS</jndi-name>
           </resource-ref>
          </jboss-web>
          


          • 2. Re: JNDI lookup of DataSource failed
            braca

            Thanks for advice! The deployment is now alright for the war, no exception is thrown. Unfortunately connecting to the dataSource still doesn't work. When requesting the page index.jspx with the sql:query, this exception is thrown:

            20:28:10,462 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
            javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.lang.NullPointerE
            xception"
            at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.j
            ava:285)
            at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java
            :168)
            at org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:94)

            However, if I place "OracleDS" directly into the jsp-Page:
            <sql:query var="queryResults" dataSource="OracleDS">
            SELECT kat1, kat2,

            it works. But only if there is a jboss-web.xml as well as you posted it.

            How can I get it to work without referencing for each jsp-Page the dataSource?

            • 3. Re: JNDI lookup of DataSource failed
              peterj

              I haven't used the sql tags, but from doing some reading it would appear that you have to set the datasource on every JSP that uses those tags. If you have multiple sql tags, you can use sql:setDataSource to set it once.

              • 4. Re: JNDI lookup of DataSource failed
                braca

                Hello,

                I found a different solution by inserting the following into web.xml:

                <context-param>
                <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
                <param-value>OracleDS</param-value>
                </context-param>

                Using this solution, I don't need to insert the dataSource in every JSP page.

                Thanks for helping me,
                braca