Bug 8283

Summary: Providing a javax.sql.DataSource object to the datasource attribute of the setDataSource action fails.
Product: Taglibs Reporter: Ryan Lubke <Ryan.Lubke>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Corrects ClassCastExceptions in SetDataSourceTagSupport

Description Ryan Lubke 2002-04-18 22:38:46 UTC

<sql:setDataSource dataSource="${jstlDS}" var='driverInfoDS' />


root cause
> javax.servlet.jsp.JspTagException: In <driver>, invalid driver class name: "
>         at
>         at
>         at
>         at
Comment 1 Shawn Bayern 2002-04-18 23:05:28 UTC
Ryan, I'm not sure I understand the bug report.  The following works for me:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>

  public static class Foo implements javax.sql.DataSource {
    public java.sql.Connection getConnection() { return null; }
    public java.sql.Connection getConnection(String a, String b) {
       return null; }
    public int getLoginTimeout() { return 0; }
    public java.io.PrintWriter getLogWriter() { return null; }
    public void setLoginTimeout(int a) { }
    public void setLogWriter(java.io.PrintWriter a) { }
  pageContext.setAttribute("myDataSource", new Foo());

  var="new" dataSource="${myDataSource}" />


Is the problem that the driver within the String representation of a DataSource 
you're passing isn't valid?  If so, that's an issue we're waiting on spec 
clarification for.
Comment 2 Ryan Lubke 2002-04-19 11:23:03 UTC
I beleive the problem could be related to the fact that our DataSource overrides
the toString() method.  The Error message reported shows the result of calling
that method.
Comment 3 Ryan Lubke 2002-04-19 12:44:41 UTC
Created attachment 1631 [details]
Corrects ClassCastExceptions in SetDataSourceTagSupport
Comment 4 Ryan Lubke 2002-04-19 12:45:07 UTC
Actually, it appears Jan corrected this issue already.  The ExpressionManager
was configured to evaluate as a String instead of an Object.

However, there is now an issue with ClassCastExceptions being raised.

I've atteched a patch to this bug that corrects the issue.
Comment 5 Jan Luehe 2002-04-19 17:18:38 UTC
  - Applied Ryan's patch (thanks, Ryan!)
  - Also removed DataSourceUtil constructor, in which a
    DataSourceWrapper was allocated. This was out-of-date, since the
    wrapper now is allocated inside setUsingParams().