javax.servlet.jsp.jspl.sql.dataSource is taking precedence over the sql:transaction dataSource attribute. <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> <%@ taglib prefix="sql_rt" uri="http://java.sun.com/jstl/sql_rt" %> <%@ taglib prefix="tck" uri="http://java.sun.com/jstltck/jstltck-util" %> <%@ page import="javax.sql.*,java.util.*" %> <tck:test testName="positiveTxDataSourceConfigDataSourceTest"> <!-- EL: Validate sql:transaction, sql:query actions and javax.servlet.jsp.jstl.sql.dataSource configuration parameter specifying a DataSource Object --> <h1>Validating sql:transaction, sql:query actions, the javax.servlet.jsp.jstl.sql.dataSource configuration parameter specifying a DataSource Object using EL</h1> <p> <%-- Configure javax.servlet.jsp.jstl.sql.dataSource --%> <tck:config configVar="datasource" op="set" value='<%= (DataSource) pageContext.getAttribute("jstlDS", PageContext.APPLICATION_SCOPE) %>'/> <sql:transaction> <sql:query var="resultSet" > <c:out value="${sqlProps.Simple_Select_Query}" /> </sql:query> </sql:transaction> <c:choose> <c:when test="${resultSet.rowCount != JSTL_TAB1_ROWS}"> <H2>ERROR:</H2> While using the configuration parameter <strong> javax.servlet.jsp.jstl.sql.dataSource</strong>, and the query: <strong> "<c:out value="${sqlProps.Simple_Select_Query}" />" , the expected number of rows <strong>"<c:out value="${JSTL_TAB1_ROWS}" />"</strong> was not returned. The actual number of rows returned was <strong>"<c:out value="${resultSet.rowCount}" />"<strong>. <p> </c:when> <c:otherwise> While using the configuration parameter <strong> javax.servlet.jsp.jstl.sql.dataSource</strong>, specifying a DataSource Object, the query succeeded. <p> </c:otherwise> </c:choose> <%-- Validate that the dataSource attribute overrides the config param --%> <tck:config configVar="datasource" op="set" value='<%= new Integer(1) %>'/> <c:catch var="e" > <sql:transaction dataSource="${applicationScope.jstlDS}" > <sql:query var="resultSet1" > <c:out value="${sqlProps.Select_Jstl_Tab1_By_Id_Query}" /> </sql:query> </sql:transaction> </c:catch> <c:choose> <c:when test="${!empty e}"> <H2>ERROR:</H2> javax.servlet.jsp.jstl.sql.dataSource <strong>did</strong> take precedence over the <strong>dataSource</strong> attribute! The Exception that was raised is: <strong><c:out value='${e}' escapeXml='false' /></strong>. <p> </c:when> <c:otherwise> The dataSource attribute <strong>did</strong> take precedence over javax.servlet.jsp.jstl.sql.dataSource. The query executed without an error. <p> </c:otherwise> </c:choose> <!-- RT: Validate sql:transaction, sql:query actions and javax.servlet.jsp.jstl.sql.dataSource configuration parameter specifying a DataSource Object --> <h1>Validating sql:transaction, sql:query actions, the javax.servlet.jsp.jstl.sql.dataSource configuration parameter specifying a DataSource Object using RT</h1> <p> <%-- Configure javax.servlet.jsp.jstl.sql.dataSource --%> <tck:config configVar="datasource" op="set" value='<%= (DataSource) pageContext.getAttribute("jstlDS", PageContext.APPLICATION_SCOPE) %>'/> <sql_rt:transaction> <sql_rt:query var="resultSet2" > <%=((Properties)pageContext.getAttribute("sqlProps",PageContext.APPLICATION_SCOPE)).getProperty("Simple_Select_Query") %> </sql_rt:query> </sql_rt:transaction> <c:choose> <c:when test="${resultSet2.rowCount != JSTL_TAB1_ROWS}"> <H2>ERROR:</H2> While using the configuration parameter <strong> javax.servlet.jsp.jstl.sql.dataSource</strong>, specifying a DataSource Object, the query: <strong> "<c:out value="${sqlProps.Simple_Select_Query}" />" , the expected number of rows <strong>"<c:out value="${JSTL_TAB1_ROWS}" />"</strong> was not returned. The actual number of rows returned was <strong>"<c:out value="${resultSet2.rowCount}" />"<strong>. <p> </c:when> <c:otherwise> While using the configuration parameter <strong> javax.servlet.jsp.jstl.sql.dataSource</strong>, specifying a DataSource Object, the query succeeded. <p> </c:otherwise> </c:choose> <%-- Validate that the dataSource attribute overrides the config param --%> <tck:config configVar="datasource" op="set" value='<%= new Integer(1) %>'/> <c:catch var="e2" > <sql_rt:transaction dataSource='<%=(DataSource) pageContext.getAttribute("jstlDS", PageContext.APPLICATION_SCOPE) %>' > <sql_rt:query var="resultSet4" > <%=((Properties)pageContext.getAttribute("sqlProps",PageContext.APPLICATION_SCOPE)).getProperty("Simple_Select_Query") %> </sql_rt:query> </sql_rt:transaction> </c:catch> <c:choose> <c:when test="${!empty e2}"> <H2>ERROR:</H2> javax.servlet.jsp.jstl.sql.dataSource <strong>did</strong> take precedence over the <strong>dataSource</strong> attribute! The Exception that was raised is: <strong><c:out value='${e2}' escapeXml='false' /></strong>. <p> </c:when> <c:otherwise> The dataSource attribute <strong>did</strong> take precedence over javax.servlet.jsp.jstl.sql.dataSource. The query executed without an error. <p> </c:otherwise> </c:choose> <tck:config configVar="datasource" op="remove" /> </tck:tes
Fixed.
This now works for sql:transaction but fails for sql_rt:transaction
OK, we were passing the test below (named "positiveTxDataSourceConfigDataSourceTest"), but the test we really should have passed in order for this bug to be fixed is named "positiveTxDataSourceConfigPrecedenceTest.jsp". We now pass this test, too.