Bug 8283 - Providing a javax.sql.DataSource object to the datasource attribute of the setDataSource action fails.
Summary: Providing a javax.sql.DataSource object to the datasource attribute of the se...
Status: RESOLVED FIXED
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: unspecified
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-18 22:38 UTC by Ryan Lubke
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Corrects ClassCastExceptions in SetDataSourceTagSupport (2.01 KB, patch)
2002-04-19 12:44 UTC, Ryan Lubke
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Lubke 2002-04-18 22:38:46 UTC
Given:

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

Result:

root cause
> javax.servlet.jsp.JspTagException: In <driver>, invalid driver class name: "
URL=jdbc:sybase:Tds:ace:4100/tempdb?FAKE_METADATA=true"
>         at
org.apache.taglibs.standard.tag.common.sql.DataSourceUtil.setUsingParams(DataSourceUtil.java:176)
>         at
org.apache.taglibs.standard.tag.common.sql.DataSourceUtil.setDataSource(DataSourceUtil.java:124)
>         at
org.apache.taglibs.standard.tag.common.sql.SetDataSourceTagSupport.doStartTag(SetDataSourceTagSupport.java:110)
>         at
org.apache.taglibs.standard.tag.el.sql.SetDataSourceTag.doStartTag(SetDataSourceTag.java:104)
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());
%>

<sql:setDataSource
  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
Fixed:
  - 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().