JNDI, again, feh

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

JNDI, again, feh

Steve Sobol
I have MySQL5 jar in $JETTY_HOME/lib/ext. Also aspectjrt.jar from the
MySQL5 Connector/J tarball.

I have in my web app, the following jetty-env.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
   <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/sobol</Arg>
     <Arg>
       <New
class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
         <Set name="Url">jdbc:mysql://localhost:3306/DATABASENAME</Set>
         <Set name="User">USERNAME</Set>
         <Set name="Password">PASSWORD</Set>
       </New>
     </Arg>
   </New>
</Configure>

Yet I continue to get "No suitable driver" errors when I try to do this:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
<title>List of Suppliers</title>
<s:setDataSource dataSource="jdbc/sobol"/>
<s:query var="vendor">select * from links where active>-1 and
type='vendor' order by name</s:query>
<p style="text-align:center"><c:forEach var="vendor" begin="0"
items="${vendor.rows}">
   <c:choose><c:when test="${empty vendor.url}">${vendor.name}<br
/></c:when>
   <c:when test="${vendor.active==0}">${vendor.name}<br /></c:when>
   <c:otherwise><a
href="http://${vendor.url}">${vendor.name}</a><br></c:otherwise></c:choose>
</c:forEach></p>


The actual error is:

Unable to get connection, DataSource invalid: "java.sql.SQLException: No
suitable driver found for jdbc/sobol"

I've tried using

<s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>

and that doesn't work either.

I have a servlet that simply outputs the contents of System property
"System.class.path". Check http://sobol.com/t and you'll see that both
the mysql and aspectjrt jars are listed there.

Help :(



Thanks,
   Steve

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: JNDI, again, feh

David Yu-2
Hi Steve,

In your web.xml, was this element declared?

    <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/sobol</res-ref-name>
      <res-type> javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>

Hth,
David

On 5/16/07, Steve Sobol <[hidden email]> wrote:
I have MySQL5 jar in $JETTY_HOME/lib/ext. Also aspectjrt.jar from the
MySQL5 Connector/J tarball.

I have in my web app, the following jetty-env.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
   <New id="sobol" class=" org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/sobol</Arg>
     <Arg>
       <New
class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
         <Set name="Url">jdbc:mysql://localhost:3306/DATABASENAME</Set>
         <Set name="User">USERNAME</Set>
         <Set name="Password">PASSWORD</Set>
       </New>
     </Arg>
   </New>
</Configure>

Yet I continue to get "No suitable driver" errors when I try to do this:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
<title>List of Suppliers</title>
<s:setDataSource dataSource="jdbc/sobol"/>
<s:query var="vendor">select * from links where active>-1 and
type='vendor' order by name</s:query>
<p style="text-align:center"><c:forEach var="vendor" begin="0"
items="${vendor.rows}">
   <c:choose><c:when test="${empty vendor.url}">${vendor.name}<br
/></c:when>
   <c:when test="${ vendor.active==0}">${vendor.name}<br /></c:when>
   <c:otherwise><a
href="http://${vendor.url}">${vendor.name }</a><br></c:otherwise></c:choose>
</c:forEach></p>


The actual error is:

Unable to get connection, DataSource invalid: "java.sql.SQLException: No
suitable driver found for jdbc/sobol"

I've tried using

<s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>

and that doesn't work either.

I have a servlet that simply outputs the contents of System property
"System.class.path". Check http://sobol.com/t and you'll see that both
the mysql and aspectjrt jars are listed there.

Help :(



Thanks,
   Steve

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: JNDI, again, feh

Steve Sobol
David Yu wrote:
> Hi Steve,
>
> In your web.xml, was this element declared?

Oops. No. But it is now, and it still isn't working. Same error message.

Meanwhile, if I don't use JNDI, e.g.,

<s:setDataSource  url="jdbc:mysql://localhost/database"
                        user="username" password="password"
                        driver="com.mysql.jdbc.Driver"/>


I don't have the same problem.



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: JNDI, again, feh

jan_bartel
In reply to this post by Steve Sobol
Steve,

The MySqlConnectionPoolDataSource is designed to be used wrapped in a special
DataSource implementation on which you can call your usual getConnection()
methods, but which under the covers calls cpds.getPooledConnection().getConnection()
to return you a usable Connection object.

So I'd try using something like commons DPBCP SharedDataSource, and passing in
the instance of the MySqlConnectionPoolDataSource to it's setConnectionPoolDataSource()
method.

Oh and this will be the right way to refer to it:

<s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>

And you need to have the web.xml <resource-ref> set up as David pointed out too.

cheers
Jan


Steve Sobol wrote:

> I have MySQL5 jar in $JETTY_HOME/lib/ext. Also aspectjrt.jar from the
> MySQL5 Connector/J tarball.
>
> I have in my web app, the following jetty-env.xml
>
> <?xml version="1.0"?>
> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
> "http://jetty.mortbay.org/configure.dtd">
>
> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>    <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource">
>      <Arg>jdbc/sobol</Arg>
>      <Arg>
>        <New
> class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
>          <Set name="Url">jdbc:mysql://localhost:3306/DATABASENAME</Set>
>          <Set name="User">USERNAME</Set>
>          <Set name="Password">PASSWORD</Set>
>        </New>
>      </Arg>
>    </New>
> </Configure>
>
> Yet I continue to get "No suitable driver" errors when I try to do this:
>
> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
> <title>List of Suppliers</title>
> <s:setDataSource dataSource="jdbc/sobol"/>
> <s:query var="vendor">select * from links where active>-1 and
> type='vendor' order by name</s:query>
> <p style="text-align:center"><c:forEach var="vendor" begin="0"
> items="${vendor.rows}">
>    <c:choose><c:when test="${empty vendor.url}">${vendor.name}<br
> /></c:when>
>    <c:when test="${vendor.active==0}">${vendor.name}<br /></c:when>
>    <c:otherwise><a
> href="http://${vendor.url}">${vendor.name}</a><br></c:otherwise></c:choose>
> </c:forEach></p>
>
>
> The actual error is:
>
> Unable to get connection, DataSource invalid: "java.sql.SQLException: No
> suitable driver found for jdbc/sobol"
>
> I've tried using
>
> <s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>
>
> and that doesn't work either.
>
> I have a servlet that simply outputs the contents of System property
> "System.class.path". Check http://sobol.com/t and you'll see that both
> the mysql and aspectjrt jars are listed there.
>
> Help :(
>
>
>
> Thanks,
>    Steve
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: JNDI, again, feh

Steve Sobol
Jan Bartel wrote:

> So I'd try using something like commons DPBCP SharedDataSource, and passing in
> the instance of the MySqlConnectionPoolDataSource to it's setConnectionPoolDataSource()
> method.

Still getting the same error. Is this jetty-env.xml correct?


<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
   <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/sobol</Arg>
     <Arg>
       <New
class="org.apache.commons.dbcp.datasources.SharedPoolDataSource">
         <Set name="ConnectionPoolDataSource">
           <New
class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
             <Set name="Url">jdbc:mysql://localhost:3306/DATABASE</Set>
             <Set name="User">USER</Set>
             <Set name="Password">PASS</Set>
           </New>
         </Set>
       </New>
     </Arg>
   </New>
</Configure>


> Oh and this will be the right way to refer to it:
>
> <s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>
>
> And you need to have the web.xml <resource-ref> set up as David pointed out too.
>
> cheers
> Jan
>
>
> Steve Sobol wrote:
>> I have MySQL5 jar in $JETTY_HOME/lib/ext. Also aspectjrt.jar from the
>> MySQL5 Connector/J tarball.
>>
>> I have in my web app, the following jetty-env.xml
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
>> "http://jetty.mortbay.org/configure.dtd">
>>
>> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>>    <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource">
>>      <Arg>jdbc/sobol</Arg>
>>      <Arg>
>>        <New
>> class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
>>          <Set name="Url">jdbc:mysql://localhost:3306/DATABASENAME</Set>
>>          <Set name="User">USERNAME</Set>
>>          <Set name="Password">PASSWORD</Set>
>>        </New>
>>      </Arg>
>>    </New>
>> </Configure>
>>
>> Yet I continue to get "No suitable driver" errors when I try to do this:
>>
>> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
>> <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
>> <title>List of Suppliers</title>
>> <s:setDataSource dataSource="jdbc/sobol"/>
>> <s:query var="vendor">select * from links where active>-1 and
>> type='vendor' order by name</s:query>
>> <p style="text-align:center"><c:forEach var="vendor" begin="0"
>> items="${vendor.rows}">
>>    <c:choose><c:when test="${empty vendor.url}">${vendor.name}<br
>> /></c:when>
>>    <c:when test="${vendor.active==0}">${vendor.name}<br /></c:when>
>>    <c:otherwise><a
>> href="http://${vendor.url}">${vendor.name}</a><br></c:otherwise></c:choose>
>> </c:forEach></p>
>>
>>
>> The actual error is:
>>
>> Unable to get connection, DataSource invalid: "java.sql.SQLException: No
>> suitable driver found for jdbc/sobol"
>>
>> I've tried using
>>
>> <s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>
>>
>> and that doesn't work either.
>>
>> I have a servlet that simply outputs the contents of System property
>> "System.class.path". Check http://sobol.com/t and you'll see that both
>> the mysql and aspectjrt jars are listed there.
>>
>> Help :(
>>
>>
>>
>> Thanks,
>>    Steve
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Jetty-support mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jetty-support
>>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: JNDI, again, feh

David Yu-2
Hi Steve,

I just followed http://docs.codehaus.org/display/JETTY/DataSource+Examples  (with database specific examples)
I created the web.xml (with resource-ref) and jetty-env.xml as said on the link.
With only the configs above, it worked for me.

Your web.xml would be something like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <resource-ref>
    <description>DataSource Reference</description>
    <res-ref-name>jdbc/DSTest</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

Here's my jsp:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> 
<%@ taglib prefix="sql" uri=" http://java.sun.com/jstl/sql" %> 
<html>
    <head>
        <title>Test</title>
    </head>
<body> 
   
    <sql:setDataSource var="db" dataSource="jdbc/DSTest" />
        <sql:query var="query1" dataSource="${db}" sql="SELECT * FROM CUSTOMERS" >  
    </sql:query> 
    <table border="1"> 
    <c:forEach var="row" items="${ query1.rows}">
        <tr>
            <td><c:out value="${row.first_name}" /></td>
            <td><c:out value="${row.last_name}" /></td> 
        </tr>
    </c:forEach>
    </table>
   
     
</body>
</html>    

Hth,
David

On 5/17/07, Steve Sobol <[hidden email]> wrote:
Jan Bartel wrote:

> So I'd try using something like commons DPBCP SharedDataSource, and passing in
> the instance of the MySqlConnectionPoolDataSource to it's setConnectionPoolDataSource()
> method.

Still getting the same error. Is this jetty-env.xml correct?


<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
" http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
   <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>jdbc/sobol</Arg>
     <Arg>
       <New
class="org.apache.commons.dbcp.datasources.SharedPoolDataSource">
         <Set name="ConnectionPoolDataSource">
           <New
class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
             <Set name="Url">jdbc:mysql://localhost:3306/DATABASE</Set>
             <Set name="User">USER</Set>
             <Set name="Password">PASS</Set>
           </New>
         </Set>
       </New>
     </Arg>
   </New>
</Configure>


> Oh and this will be the right way to refer to it:
>
> <s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>
>
> And you need to have the web.xml <resource-ref> set up as David pointed out too.
>
> cheers
> Jan
>
>
> Steve Sobol wrote:
>> I have MySQL5 jar in $JETTY_HOME/lib/ext. Also aspectjrt.jar from the
>> MySQL5 Connector/J tarball.
>>
>> I have in my web app, the following jetty-env.xml
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
>> " http://jetty.mortbay.org/configure.dtd">
>>
>> <Configure class="org.mortbay.jetty.webapp.WebAppContext">
>>    <New id="sobol" class="org.mortbay.jetty.plus.naming.Resource ">
>>      <Arg>jdbc/sobol</Arg>
>>      <Arg>
>>        <New
>> class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
>>          <Set name="Url">jdbc:mysql://localhost:3306/DATABASENAME</Set>
>>          <Set name="User">USERNAME</Set>
>>          <Set name="Password">PASSWORD</Set>
>>        </New>
>>      </Arg>
>>    </New>
>> </Configure>
>>
>> Yet I continue to get "No suitable driver" errors when I try to do this:
>>
>> <%@taglib uri=" http://java.sun.com/jsp/jstl/core" prefix="c"%>
>> <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
>> <title>List of Suppliers</title>
>> <s:setDataSource dataSource="jdbc/sobol"/>
>> <s:query var="vendor">select * from links where active>-1 and
>> type='vendor' order by name</s:query>
>> <p style="text-align:center"><c:forEach var="vendor" begin="0"
>> items="${vendor.rows}">
>>    <c:choose><c:when test="${empty vendor.url}">${vendor.name}<br
>> /></c:when>
>>    <c:when test="${vendor.active==0}">${vendor.name}<br /></c:when>
>>    <c:otherwise><a
>> href="http://${vendor.url}">${vendor.name}</a><br></c:otherwise></c:choose>
>> </c:forEach></p>
>>
>>
>> The actual error is:
>>
>> Unable to get connection, DataSource invalid: "java.sql.SQLException: No
>> suitable driver found for jdbc/sobol"
>>
>> I've tried using
>>
>> <s:setDataSource dataSource="java:comp/env/jdbc/sobol"/>
>>
>> and that doesn't work either.
>>
>> I have a servlet that simply outputs the contents of System property
>> "System.class.path". Check http://sobol.com/t and you'll see that both
>> the mysql and aspectjrt jars are listed there.
>>
>> Help :(
>>
>>
>>
>> Thanks,
>>    Steve
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Jetty-support mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jetty-support
>>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support