I usually use Jboss and Tomcat combination. Once in a while I have to use Tomcat only, this is one of those times. This exception has been occuring since 2004 it looks like. But, since I rarely use Tomcat I am reporting it today. :)
I was trying to set up a JDBC DataSource using JNDI on tomcat and I receieved this SQLNestedException. I decided to log the error and let you in on the possible fix. The big thing to note is that now you no longer have resource-params like you used to. You now have to set up your JNDI resources by attribute only. In other words, database resources have gone from:
This:
<Context ...>
...
<Resource name="jdbc/EmployeeDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeDB">
<parameter>
<name>username</name>
<value>dbusername</value>
</parameter>
<parameter>
<name>password</name>
<value>dbpassword</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.hsql.jdbcDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:HypersonicSQL:database</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>8</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>
</ResourceParams>
...
</Context>
To This:
<Context ...>
...
<Resource name="jdbc/EmployeeDB" auth="Container"
type="javax.sql.DataSource" username="dbusername" password="dbpassword"
driverClassName="org.hsql.jdbcDriver" url="jdbc:HypersonicSQL:database"
maxActive="8" maxIdle="4"/>
...
</Context>
Here is the stack trace that you may similarily have seen
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:388)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:283)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
... 36 more

Wed, 26 Oct 2005 02:19 PM GMT
This is a wonderful insight. It solved my problem. Greatly Appreciated. Thanks again...
Thu, 27 Oct 2005 09:43 AM GMT
But big question is ¿Why resource-params doesn't work anymore?
Wed, 16 Nov 2005 02:38 AM GMT
Thanks Daniel! I was struggling with this on Tomcat 5.5.9 for 4 days, and finally came across your site via Google. Would have been nice if Apache Foundation would have notified users of the change, huh. Job well done!
Thu, 8 Dec 2005 06:41 PM GMT
It just solved the problem which confused me couple days ago. Thanks a lot.
Mon, 12 Dec 2005 12:58 PM GMT
Brilliant. Thanks Daniel. This works perfectly well for me. Its unfortunate that users were not notified of the changes in tomcat. I am running tomcat 5.5.12, so if you have the same trouble then set up your JNDI resources by attribute only as posted by Daniel (above)
Sat, 25 Feb 2006 11:44 AM GMT
Great stuff, Daniel. Thanks for sharing this info. Alessio
Mon, 3 Apr 2006 08:53 AM GMT
Thanks Daniel, I was struck up for 2 days because of this.
Wed, 5 Apr 2006 05:20 AM GMT
Thanks! This rocks!
Mon, 10 Apr 2006 10:11 PM GMT
And for Tomcat 5.0.*.* which is the correct configuration ? With the first one I get an SQLNestedException but on Tomcat site the suggested configuration is just that one... ???
Tue, 11 Apr 2006 09:13 PM GMT
Do you have more info?
Thu, 13 Apr 2006 10:10 AM GMT
Do You are talking with me ? I've tried to change the configuration but I get the same error again...
Thu, 13 Apr 2006 04:28 PM GMT
Yes, Ed, send me what you got to dhinojosa {at} evolutionnext {dot} com. :)
Tue, 18 Apr 2006 12:42 PM GMT
Thank you very much,It solved my problem!But Why tomcat throw this exception?
Wed, 26 Apr 2006 08:22 AM GMT
I can not upload pictures in 'Togetherweserved" Error I get: Description: The server encountered an internal error () that prevented it from fulfilling this request
Tue, 2 May 2006 09:57 AM GMT
I am still unable to configure the Datasource, still throwing the same error. I have Included this in the servet.xml
I saw there is a error message as follows:
Caused by:
java.lang.NullPointerException at org.apache.derby.jdbc.InternalDriver.acceptsURL(Unknown Source)
at java.sql.DriverManager.getDriver(DriverManager.java:232)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773) ... 22 more
If you know how to fix this... help great appreciated...
Thanks
Wed, 3 May 2006 01:14 AM GMT
Blitzz, Judging by some of the documentation, the url cannot have backslashes. e.g. from http://publib.boulder.ibm.com/infocenter/cldscp10/index.jsp?topic=/com.ibm.cloudscape.doc/develop11.htm # jdbc:derby:a:/demo/sample Open a connection to the database stored in the directory \demo\sample on drive A (usually the floppy drive) on a Windows system. # jdbc:derby:c:/databases/salesdb jdbc:derby:salesdb These two connection URLs connect to the same database, salesdb, on a Windows platform if the system directory of the Cloudscape system is C:\databases.
Thu, 4 May 2006 02:58 PM GMT
Hi all Please Hlep me on this I am connecting to oracle by creating datasource but i m getting the below error I am using 1. oracle 9i 2. Tomcate 5.5.16. I have gone through document from the tomcat site. org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at foo.ConnectionPool.init(ConnectionPool.java:34) at org.apache.jsp.page_jsp._jspService(page_jsp.java:48) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source) Caused by: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(Unknown Source) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773) ... 23 more
Mon, 15 May 2006 12:12 AM GMT
THANKS FOR SAVING MY HIDE! Not that I'd have failed to figure it out :-), but you saved me before I spent the couple hours on it. My Tomcat 5.5.x upgrade was ten minutes!
Mon, 15 May 2006 02:15 AM GMT
Good post Daniel! I've been with this problem for some days and now it's solved. Has this problem started with Tomcat 5.5.x?
Mon, 15 May 2006 05:52 AM GMT
org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92) at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:301) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:110) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162) at org.hibernate.loader.Loader.doQuery(Loader.java:390) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603) at com.ipt.bo.IPTSubscriberBO.articleInVault(Unknown Source) at com.ipt.bo.IPTSubscriberBO.articleInVaultStatus(Unknown Source) at com.ipt.bo.IPTSDESvcMgr.articleView(Unknown Source) at com.ipt.ctrlr.IPTSDECtrlr.doSDEService(Unknown Source) at com.ipt.ctrlr.IPTSDECtrlr.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool exhausted at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:298) ... 34 more Caused by: java.util.NoSuchElementException: Timeout waiting for idle object at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:756) at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95) ... 37 more
Wed, 17 May 2006 04:38 PM GMT
Hi, m using tomcat 4.1.30, still m getting an exception if i use attributes instead of params in Resource tag within context tag of server.xml Exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: null
Sat, 27 May 2006 01:53 AM GMT
thank, you save my life
Fri, 2 Jun 2006 11:25 AM GMT
Hi I have the same problem. My application is accessible over the context name www.bfcinternational.com/bfcinternational/ but when I create a "response.sendRedirect("bfcinternational");" I got the error listed above. What's the problem. Thanks in advance
Sat, 3 Jun 2006 09:56 PM GMT
Your kudos is well deserved. Thanks for your post!
Mon, 5 Jun 2006 05:27 AM GMT
Hello! I got the same error but I think my configuration file is OK. The java file is listed bellow. I cannot figour out what is wrong. Please help!
Fri, 9 Jun 2006 09:27 AM GMT
I have encountered the following error message :- org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory, cause: java.sql.SQLException: Data source rejected establishment of connection, message from server: "#HY000Host 'localhost.localdomain' is not allowed to connect to this MySQL server" at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:650) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808) at com.mysql.jdbc.Connection.
Thu, 29 Jun 2006 05:30 AM GMT
Hi Experts, I have a proble in jndi connection in Tomcat 4.1, please I need help on this. Here is the details. Exception: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) ********************************** JNDI configuration in server.xml:
Wed, 2 Aug 2006 09:12 AM GMT
Thanks a lot Daniel. I was struggling with this on Tomcat 5.5.17 for few hours. Att: Laura Zapata from Ecuador
Tue, 8 Aug 2006 12:32 PM GMT
HI experts I tried all these.I m working with 5.5.17.But still i m getting the error SQLNestedException - Cannot create poolable ConnectionFactory.Kindly help me.
Wed, 9 Aug 2006 09:07 AM GMT
Mon, 28 Aug 2006 03:00 PM GMT
Hi, i have the same problem. I am using resourc tag as
Mon, 28 Aug 2006 04:01 PM GMT
Incredible! I had the same problem with Tomcat 5.5.16... Ich searched 3 days and looked around the whole tomcat-website! And the solution is, that the
Tue, 12 Sep 2006 05:14 PM GMT
Has anyone ever successfully gotten an Application-managed (auth=Application) DataSource to work? When trying to open the connection using Datasource.getConnection(...), I pass in the correct username and password, but it doesn't work. The error String back from Oracle says invalid username/password. Everything worked fine with auth=Container and the correct username/password specified in the
Tue, 17 Oct 2006 10:28 PM GMT
Good job, I was trying to do it from last couple of days. Finally got your comments, it is working now.
Sat, 6 Jan 2007 09:09 PM GMT
You need to tell people over at Apache this so that they can fix there example that they show and led me to beleive their incorrect example was right. Wow thanks a lot.
Tue, 9 Jan 2007 08:44 PM GMT
Great Work Daniel! You saved Moolah...
Tue, 3 Apr 2007 08:56 AM GMT
Thanks a lot Daniel! I was struggling with this issue on Tomcat 5.5.20 for couple of days, and finally happened to see your blog via Google. Though people are facing/reporting this issue since 2005, wonder why Apache Foundation did not update the JNDI configuration page in tomcat site for the changes. It solved my problem. Well Appreciated!
Mon, 18 Jun 2007 06:23 PM GMT
Thank you so much for this solution. I would have burned rubber on this forever.
Fri, 29 Jun 2007 03:06 PM GMT
Excellent!! This issue was trubbling us since a long... Thanks a ton!
Fri, 31 Aug 2007 01:59 PM GMT
Hi,
I'm using Tomcat 5.5.23 and I have error: no suitable driver.
I tried to change my server.xml as I red but it stil doesn't works.
Is it correct mapping datasource in server.xml, or have I to map it into META-INF/context.xml?
Is there a problem with ojdbc14.jar?
Have I to put it into common/lib or server/lib?
Please help!!!!!
Thanks a lot
Tue, 4 Sep 2007 08:48 AM GMT
Hi, I tried following instructions to configure my DataSource, but now I get error:
Cannot create PoolableConnectionFactory at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
This is my context.xml file
<font color="#008080" size="2"> <p align="left">< <p align="left">< <p align="left"> <p align="left"> <p align="left"> <p align="left"> <p align="left"> <p align="left"> <p align="left"> <p align="left"> <p align="left"></
</font><font color="#3f7f7f" size="2">Context </font><font color="#7f007f" size="2">docBase</font><font size="2">=</font><font color="#2a00ff" size="2">"myContext" </font><font color="#7f007f" size="2">path</font><font size="2">=</font><font color="#2a00ff" size="2">"/myContext" </font><font color="#7f007f" size="2">reloadable</font><font size="2">=</font><font color="#2a00ff" size="2">"true"</font><font color="#008080" size="2">></font><font color="#3f7f7f" size="2">Resource </font><font color="#7f007f" size="2">name</font><font size="2">=</font><font color="#2a00ff" size="2">"jdbc/myds" </font><font color="#7f007f" size="2">auth</font><font size="2">=</font><font color="#2a00ff" size="2">"Container" </font><font color="#7f007f" size="2">type</font><font size="2">=</font><font color="#2a00ff" size="2">"javax.sql.DataSource" </font><font color="#7f007f" size="2">user</font><font size="2">=</font><font color="#2a00ff" size="2">"user" </font><font color="#7f007f" size="2">password</font><font size="2">=</font><font color="#2a00ff" size="2">"password" </font><font color="#7f007f" size="2">driverClassName</font><font size="2">=</font><font color="#2a00ff" size="2">"oracle.jdbc.driver.OracleDriver" </font><font color="#7f007f" size="2">url</font><font size="2">=</font><font color="#2a00ff" size="2">"jdbc:oracle:thin:@host:port:sid" </font><font color="#7f007f" size="2">maxActive</font><font size="2">=</font><font color="#2a00ff" size="2">"100" </font><font color="#7f007f" size="2">maxIdle</font><font size="2">=</font><font color="#2a00ff" size="2">"30" </font><font color="#7f007f" size="2">maxWait</font><font size="2">=</font><font color="#2a00ff" size="2">"5000"</font><font color="#008080" size="2">/></font><font color="#3f7f7f" size="2">Context</font><font color="#008080" size="2">></font>Can anyone help me?
Thanks
Mon, 17 Dec 2007 05:08 AM GMT
Thank u so much! I have been struggling with this problem for a week now..who'da thought that the solution was actually so simple....thanks man....perfect solution! ;-)
Fri, 18 Jan 2008 11:55 AM GMT
Amazing Maaaan, My Sinciere thanks to you! I was knocking my head placing <context> in several places and nesting it with diferent tags, I shall notify Apache soon!