Doh!, This is my fault... I tried to set the dataSource earlier by doing a :

  <c:set var="ds"><%= ds %></c:set>

Once I realized that this was going to cause the objects toString() 
method to be called, I changed the code to do:

    request.setAttribute("ds", ds);


Well, I forgot to remove the <c:set> which was stomping on the 
request.setAttribute. Sorry :) It works fine like this now... I'm still 
wondering why I can't find the JNDI resource by just calling 
dataSource="dev" or dataSource="jdbc/dev" but this will work for now. 
I'll just stick it in my header template.

Mike Cantrell wrote:

> I'm browsing through the source of  DataSourceUtil.java and the 
> Exception is generated here:
>
>         if (rawDataSource instanceof String) {
>             try {
>                 Context ctx = new InitialContext();
>                 // relative to standard JNDI root for J2EE app
>                 Context envCtx = (Context) ctx.lookup("java:comp/env");
>                 dataSource = (DataSource) envCtx.lookup((String) 
> rawDataSource);
>             } catch (NamingException ex) {
>                dataSource = getDataSource((String) rawDataSource); // 
> this is line 111
>             }
>         } else if (rawDataSource instanceof DataSource) {
>             dataSource = (DataSource) rawDataSource;
>         } else {
>         throw new JspException(
>                 Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE"));
>     }
>
> Now assuming that rawDataSource is the Object found with 
> findAttribute(), this should defeinitely not be a String since it was 
> put there as a DataSource Object:
>
>
>     <%
>        javax.naming.InitialContext ctx = new 
> javax.naming.InitialContext();
>         javax.sql.DataSource ds = (javax.sql.DataSource) 
> ctx.lookup("dev");
>         request.setAttribute("ds", ds);
>     %>
>
>
>
>
> Mike Cantrell wrote:
>
>> Well, I tried that just now and I had the same result.
>>
>> I just tried getting the DataSource manually and feeding it to the 
>> tag and got a little more descriptive error:
>>
>>     <%
>>        javax.naming.InitialContext ctx = new 
>> javax.naming.InitialContext();
>>         javax.sql.DataSource ds = (javax.sql.DataSource) 
>> ctx.lookup("dev");
>>         request.setAttribute("ds", ds);
>>     %>
>>     <sql:query dataSource="${ds}" var="test">
>>         select * from dn_user
>>     </sql:query>
>>     <c:forEach var="row" items="${test.rows}">
>>         <c:out value="${row.login}" />
>>     </c:forEach>
>>
>>
>> This produces:
>>
>>     javax.servlet.jsp.JspTagException: In <driver>, invalid driver 
>> class name: " PoolName: dev]"
>>
>> Now, I've got to think it's something wrong with how JRun is setting 
>> up the Pooled DataSources but I can't understand how it works with 
>> the dbTag libs. Strange?  Does anyone know what's going on at the 
>> source level here? Here's the complete stackTrace:
>>
>>
>> javax.servlet.jsp.JspTagException: In &lt;driver&gt;, invalid driver 
>> class name:
>>  " PoolName: dev]"
>>         at 
>> org.apache.taglibs.standard.tag.common.sql.DataSourceUtil.getDataSour
>> ce(DataSourceUtil.java:165)
>>         at 
>> org.apache.taglibs.standard.tag.common.sql.DataSourceUtil.getDataSour
>> ce(DataSourceUtil.java:111)
>>         at 
>> org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnect
>> ion(QueryTagSupport.java:303)
>>         at 
>> org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag
>> (QueryTagSupport.java:192)
>>         at 
>> org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.j
>> ava:125)
>>         at jrun__test2ejsp9._jspService(jrun__test2ejsp9.java:93)
>>         at 
>> jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
>>         at jrun.jsp.JSPServlet.service(JSPServlet.java:106)
>>         at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
>>         at 
>> jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
>>         at 
>> jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:
>> 241)
>>         at 
>> jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:
>> 527)
>>         at 
>> jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
>>         at 
>> jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPoo
>> l.java:348)
>>         at 
>> jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.j
>> ava:451)
>>         at 
>> jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.
>> java:294)
>>         at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
>>
>>
>>
>> Kan Ogawa wrote:
>>
>>>Hi, Mike.
>>>
>>>Did you try to look up dataSource "jdbc/dev" in <sql:query> tag ???
>>>
>>>--
>>>Kan Ogawa
>>>[EMAIL PROTECTED]
>>>
>>>  
>>>
>>>>I'm trying to use the sql JSTL tags on JRun 4.0 and I'm not having any 
>>>>luck with their pooled dataSources. I get the following error:
>>>>
>>>>     javax.servlet.jsp.JspException: Unable to get connection, 
>>>>DataSource invalid: "No suitable driver"
>>>>
>>>>Here's how I'm using the tag:
>>>>
>>>>    <%@ taglib uri="/WEB-INF/tlds/sql.tld" prefix="sql" %>
>>>>    <%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>   
>>>>        <sql:query dataSource="dev" var="test">
>>>>            select * from dn_user
>>>>        </sql:query>
>>>>        <c:forEach var="row" items="${test.rows}">
>>>>            <c:out value="${row.login}" />
>>>>        </c:forEach>
>>>>
>>>>I also tried calling it with dataSource="java:comp/env/jdbc/dev" as 
>>>>well. I thought it must be JRun so I tried grabbing the DataSource 
>>>>manually and I had no problems:
>>>>
>>>>    InitialContext ctx = new InitialContext();
>>>>    DataSource ds = (DataSource) ctx.lookup("dev"); // works with 
>>>>java:comp/env/jdbc/dev also
>>>>    Connection dbConnection = ds.getConnection();
>>>>
>>>>I also tried the dbtaglibs which worked fine as well:
>>>>
>>>>    <%@ taglib uri="/WEB-INF/tlds/dbtags.tld" prefix="sql" %>
>>>>      <sql:connection id="conn1" jndiName="dev"/>
>>>>            <sql:statement id="stmt1" conn="conn1">
>>>>                <sql:query>
>>>>                 select * from dn_user
>>>>                </sql:query>
>>>>                <sql:resultSet id="rset2">
>>>>                    <sql:getColumn position="1"/><br>
>>>>                </sql:resultSet>
>>>>           </sql:statement>
>>>>        <sql:closeConnection conn="conn1"/>
>>>>
>>>>I have no idea what's wrong. I must be missing something but I'm not 
>>>>sure what it is.  Ugh, I need help :)
>>>>
>>>>    
>>>>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>>>
>>>  
>>>
>>
>

Reply via email to