The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: Unable to get JDBC connections via sql tags using JSTL

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Sep 24, 2007 5:50 PM by: kmiya
kmiya

Posts: 7
Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 21, 2007 12:36 AM
 
  Click to reply to this thread Reply

Hello,

I have a problem using sql JSTL tags to connect to databases, where the JSP fails with a JspException saying
Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/foo"

The strange thing is, trying to connect to the very same datasource using JPA works just fine.

The database I'm trying to connect to is a PostgreSQL database, but I don't think that is relavant, since trying
<sql:setDataSource dataSource="jdbc/__CallFlowPool" var="test" />
using the built-in sample data source, also fails, even though the connection pool PING works without any problems.

I am using a fresh install of Glassfish v2-b49 and v2-b58 on Windows XP sp2 and Vista Ultimate.
I have copied PostgreSQL driver JAR (postgresql-8.1-409.jdbc3.jar) to $GLASSFISH_HOME/domain/domain1/lib/ext .

I am guessing that the error message is not getting to the heart of the problem, since trying to connect to a bogus datasource using
<sql:setDataSource dataSource="jdbc/bogusNonExsistingDataSource" var="test" />
yields the same error message. I have a suspicion that it is not the Driver that the server is unable to find, but is the JNDI resource itself.

I have tried everything I can think of, and totally at a loss. Can anyone help me please?

jr158900

Posts: 323
Re: Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 21, 2007 1:25 AM   in response to: kmiya
 
  Click to reply to this thread Reply

Could this be due to one of the issues as discussed in :
http://forum.java.sun.com/thread.jspa?threadID=487314&messageID=4066954

kmiya

Posts: 7
Re: Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 21, 2007 2:06 AM   in response to: jr158900
 
  Click to reply to this thread Reply

Thank you for the quick response, jr158900.

I am sorry, but I forgot to mention in the first post that the web application itself is currently working on Tomcat, so I don't think the problem resides in the source code. I am planning a transition of the server from Tomcat to Glassfish, but am unable because of the JSTL issue in discussion.

Glassfish currently does not make use of the resource definitions in WEB-INF/context.xml file that Tomcat uses, so instead I created a connection pool and a JDBC resource in the admin GUI to be used from my web application. The mystery is that the ping to the connection pool works, but the JSTL sql tag does not.

lancea

Posts: 61
Re: Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 21, 2007 1:18 PM   in response to: kmiya
 
  Click to reply to this thread Reply

Can u post a complete stripped down sample which shows the problem and is deployable?

cobrien

Posts: 22
Re: Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 24, 2007 6:18 AM   in response to: kmiya
 
  Click to reply to this thread Reply

I had problems with this, but I don't have an exact simple example handy.
I had problems with the JNDI lookup. The JNDI browser in Glassfish didn't
show me what I expected i.e. jndi/(pool-name).
I ended up using the java code shown here:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
To see what JNDI resources were available. Note that listing the
JNDI contexts didn't work like I expected, I still don't understand why.
I THINK I had to leave off the jndi, or set up a resource-reference or
something.

I wish I had a simpler answer, or at least one better than "stick with tomcat"
(which is what I find myself doing).

kmiya

Posts: 7
Re: Unable to get JDBC connections via sql tags using JSTL
Posted: Sep 24, 2007 5:50 PM   in response to: cobrien
 
  Click to reply to this thread Reply

Sorry folks, my mistake.

I found that I had not created my WEB-INF/web.xml file correctly; I had forgotten to add a <resource-ref> configuration to enable my datasource.

I guess Tomcat works w/o this configuration, since they use the <Resource> tag in META-INF/context.xml.

So you were right, cobrien, "set up a resource-reference" was the answer for me.

Oh, and another culprit was, you need to recreate your JDBC resource once you make changes to its underlying connection pool (restarting Glassfish won't help).

I still think that the error message(No suitable driver) is misleading and incorrect, though.

Thank you all for your time and advise.




 XML java.net RSS