3 Replies Latest reply on Jul 9, 2007 7:33 PM by Chris Young

    JSTL sql:setDataSource and JCA

    Chris Young Newbie

      I'm having trouble getting sql:setDataSource in my Jakarta standard 1.1.2 tag library to work with my JCA Sybase SQL Anywhere data source. I am using JBoss AS 4.0.1sp1

      This code works fine:
      <sql:setDataSource url="jdbc:sybase:Tds:localhost:2638" driver="com.sybase.jdbc2.jdbc.SybDataSource" user="dba" password="sql" />

      but this code:
      <sql:setDataSource dataSource="java:asa" />

      generates:
      javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
      org.apache.jsp.readermessages_jsp._jspService(readermessages_jsp.java:287)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

      I believe my name is correct as the JNDI same name is used throughout my code. However, no matter what name I use, I get the same error.

      I have tried many variations on the name, including "jdbc/asa" as discussed in various Sun tutorial documents, but I get nowhere.

      Before I investigate different JSTL implentations are versions, is there a trick to make JSTL work with JCA?

      Thanks in advance.

        • 1. Re: JSTL sql:setDataSource and JCA
          Steven Ostrowski Newbie

          I have the same problem with Tomcat and Oracle driver.

          I have my oracle-ds.xml in the deploy directory and it deploys fine in my application. I'm trying to write a quick test JSP using the JSTL SQL tag. I've tried setDataSource as well as specifying the datasource directly in the sql:query attribute.

          Both of them give No Suitable Driver.

          I put the driver in deploy/lib (where it was), and I also tried putting it in WEB-INF/lib but that failed as well.

          • 2. Re: JSTL sql:setDataSource and JCA
            Vinit Sacheti Newbie

            Can anybody who has resolved this problem reply to this?

            Thanks

            • 3. Re: JSTL sql:setDataSource and JCA
              Chris Young Newbie

              I finally figured out that JBoss does not conform to the J2EE standard for storing the DataSource references in their JNDI repository. I don't remember at the moment what the standard is (something like java.env:DataSourceName), but it is not referenceable as java:DataSourceName.

              So, I registered it within the ServletContext as a variable during startup in the ContextListener:
              dataSource = (DataSource) initialContext.lookup("java:asa");
              servletContext.setAttribute("asa", dataSource);

              Then I was able to reference it in the JSP as:
              <sql:setDataSource dataSource="${asa}" />

              That seemed to do the trick.

              I hope that helps!