You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thomas Okken <to...@ncstech.com> on 2007/12/07 18:14:10 UTC
DataSource created but not initialized => Cannot create JDBC driver
of class '' for connect URL 'null'
Hi all,
I'm trying to set up a DataSource to manage connections to a MySQL
database, but whenever I call getConnection(), I get this error:
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:1150)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
...
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:1143)
...
The datasource is defined in a file called
$TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context path
is /smm); it looks like this:
<Context path="/smm" docBase="smm" debug="5" reloadable="true"
crossContext="true">
<Resource name="jdbc/SmmDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="wmmdev" password="wmmdev"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
</Context>
The fact that the datasource gets created and bound in JNDI tells me
that smm.xml is getting read, but apparently it is not getting
initialized properly; getDriverClassName(), getUrl(), getUsername(), and
getPassword() all return null, and it looks like that's what causes the
exception in getConnection().
I've seen quite a few questions about this error, but in the archived
threads on this mailing list, I haven't found any solution to this
particular problem... One poster who had the same diagnosis mentioned
that the problem went away when he got rid of the Context element in
META-INF/context.xml, but in my case, that file does not exist; in fact,
the only Context elements I have are the one shown above, and the
standard one in $TOMCAT_HOME/conf/context.xml.
The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but I'm
not sure that's relevant because, first of all, DriverManager will only
use drivers that were loaded by the same class loader as itself, and
second, the DataSource can't use the driver anyway as long as its
driverClassName and url properties remain unset.
I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
mysql-connector-java-5.1.5-bin.jar.
I'm stumped... Any thoughts would be much appreciated!
- Thomas
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBCdriver
of class '' for connect URL 'null'
Posted by Thomas Okken <to...@ncstech.com>.
OK, I removed the path and docBase attributes from the Context element;
as expected, the warning in the log goes away but the DataSource problem
does not.
The mysql-connector-java-5.1.5-bin.jar file is world-readable; it is in
$TOMCAT_HOME/lib and nowhere else; I did have another copy in
$TOMCAT_HOME/common/lib per a suggestion in a different thread, but that
made no difference so I removed it.
- Thomas
Caldarale, Charles R wrote:
>> From: Thomas Okken [mailto:tokken@ncstech.com]
>> Subject: Re: DataSource created but not initialized => Cannot
>> create JDBCdriver of class '' for connect URL 'null'
>>
>> There is a warning about the docBase attribute (strange; I
>> copied that text verbatim from the Tomcat FAQ); if I remove
>> that attribute, the warning goes away, but the DataSource
>> remains uninitialized.
>>
>
> The FAQ is out of date for 5.5 and later levels.
>
> You should also remove the path attribute, since it's illegal when the
> <Context> element is not in server.xml (and such elements should never
> be in server.xml).
>
> The docBase attribute is illegal unless the app is located somewhere
> outside of the <Host>'s appBase directory.
>
> However, neither of the above is causing your DB connection problem.
>
> Have you checked permissions on the mysql-connector-java-5.1.5-bin.jar
> to make sure Tomcat can read it?
>
> Does that jar (or any MySQL jar) also exist in the webapp's WEB-INF/lib
> directory? If so, remove it; it shouldn't be in two places at once.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
RE: DataSource created but not initialized => Cannot create JDBCdriver of class '' for connect URL 'null'
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Thomas Okken [mailto:tokken@ncstech.com]
> Subject: Re: DataSource created but not initialized => Cannot
> create JDBCdriver of class '' for connect URL 'null'
>
> There is a warning about the docBase attribute (strange; I
> copied that text verbatim from the Tomcat FAQ); if I remove
> that attribute, the warning goes away, but the DataSource
> remains uninitialized.
The FAQ is out of date for 5.5 and later levels.
You should also remove the path attribute, since it's illegal when the
<Context> element is not in server.xml (and such elements should never
be in server.xml).
The docBase attribute is illegal unless the app is located somewhere
outside of the <Host>'s appBase directory.
However, neither of the above is causing your DB connection problem.
Have you checked permissions on the mysql-connector-java-5.1.5-bin.jar
to make sure Tomcat can read it?
Does that jar (or any MySQL jar) also exist in the webapp's WEB-INF/lib
directory? If so, remove it; it shouldn't be in two places at once.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBC
driver of class '' for connect URL 'null'
Posted by Thomas Okken <to...@ncstech.com>.
You're right, it was a typo! I called the datasource SmmDS everywhere,
except in the Context element, where I mistakenly called it SmmDB.
I think it's pretty weird that the JNDI lookup succeeded anyway. That
sounds like a Tomcat bug; it should throw a NameNotFoundException, not
return an uninitialized object.
Anyway, it's working perfectly now. My sincere thanks to everyone who
responded!
- Thomas
David Smith wrote:
> Ok...
>
> The other statistical common thread in this type of issue is a typo or
> missing config somewhere along the line in one of these files:
>
> context.xml -- you've provided that and named the resource jdbc/SmmDB
>
> web.xml -- do you have this in your WEB-INF/web.xml:
> <resource-ref>
> <res-ref-name>jdbc/SmmDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> your java source code -- did you try to fech the DataSource using the
> path 'java:/comp/env/jdbc/SmmDB'?
>
> Case is important all the way through this as well. FWIW the Resource
> element you posted below looks fine -- good case, valid attributes,
> etc., ...
> Two things you might want to consider once your db pool starts working
> is removing autoReconnect=true from your database url and adding
> validationQuery="select 1". Autoreconnect doesn't re-establish a
> connection until a request has failed -- makes it virtually useless in
> a db pool. validationQuery="select 1" as a Resource attribute causes
> the database pool to test the connection with a simple query on
> borrowing.
>
> --David
>
> Thomas Okken wrote:
>
>> The MySQL driver is in $TOMCAT_HOME/lib, but I don't think that is
>> even the issue here -- the real problem is that the DataSource object
>> is not initialized, so it doesn't even have the url, driver class
>> name, etc.
>> This is what my log looks like when I restart Tomcat:
>>
>> Dec 7, 2007 1:18:50 PM org.apache.catalina.core.AprLifecycleListener
>> init
>> INFO: The Apache Tomcat Native library which allows optimal
>> performance in production environments was not found on the
>> java.library.path:
>> /home/tokken/software/jdk1.5.0_11/bin:/home/tokken/apache-tomcat-6.0.14/bin
>>
>> Dec 7, 2007 1:18:51 PM org.apache.coyote.http11.Http11Protocol init
>> INFO: Initializing Coyote HTTP/1.1 on http-8888
>> Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.Catalina load
>> INFO: Initialization processed in 729 ms
>> Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardService start
>> INFO: Starting service Catalina
>> Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardEngine start
>> INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
>> Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.HostConfig
>> deployDescriptor
>> WARNING: A docBase /home/tokken/apache-tomcat-6.0.14/webapps/smm
>> inside the host appBase has been specified, and will be ignored
>> Dec 7, 2007 1:18:52 PM org.apache.struts.action.ActionServlet initChain
>> INFO: Loading chain catalog from
>> jar:file:/home/tokken/apache-tomcat-6.0.14/webapps/smm/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
>>
>> Dec 7, 2007 1:18:53 PM org.apache.catalina.startup.HostConfig deployWAR
>> INFO: Deploying web application archive BBYPServer.war
>> Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
>> INFO: ContextListener: contextInitialized()
>> Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
>> INFO: SessionListener: contextInitialized()
>> Dec 7, 2007 1:18:53 PM org.apache.coyote.http11.Http11Protocol start
>> INFO: Starting Coyote HTTP/1.1 on http-8888
>> Dec 7, 2007 1:18:53 PM org.apache.jk.common.ChannelSocket init
>> INFO: JK: ajp13 listening on /0.0.0.0:8009
>> Dec 7, 2007 1:18:54 PM org.apache.jk.server.JkMain start
>> INFO: Jk running ID=0 time=0/43 config=null
>> Dec 7, 2007 1:18:54 PM org.apache.catalina.startup.Catalina start
>> INFO: Server startup in 3005 ms
>>
>> There is a warning about the docBase attribute (strange; I copied
>> that text verbatim from the Tomcat FAQ); if I remove that attribute,
>> the warning goes away, but the DataSource remains uninitialized.
>>
>> - Thomas
>>
>> David Smith wrote:
>>
>>> Where did you place your mysql driver jar file? It has to be in
>>> tomcat's /lib directory to be visible to tomat's internal code for
>>> building the db pool and your webapp. Also did you happen to look
>>> at the logs around when your webapp started for any relevant messages?
>>>
>>> --David
>>>
>>> Thomas Okken wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm trying to set up a DataSource to manage connections to a MySQL
>>>> database, but whenever I call getConnection(), I get this error:
>>>>
>>>> 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:1150)
>>>>
>>>> at
>>>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>>>>
>>>> ...
>>>> 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:1143)
>>>>
>>>> ...
>>>>
>>>>
>>>> The datasource is defined in a file called
>>>> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context
>>>> path is /smm); it looks like this:
>>>>
>>>> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
>>>> crossContext="true">
>>>> <Resource name="jdbc/SmmDB" auth="Container"
>>>> type="javax.sql.DataSource"
>>>> maxActive="100" maxIdle="30" maxWait="10000"
>>>> username="wmmdev" password="wmmdev"
>>>> driverClassName="com.mysql.jdbc.Driver"
>>>>
>>>> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
>>>>
>>>> </Context>
>>>>
>>>> The fact that the datasource gets created and bound in JNDI tells
>>>> me that smm.xml is getting read, but apparently it is not getting
>>>> initialized properly; getDriverClassName(), getUrl(),
>>>> getUsername(), and getPassword() all return null, and it looks like
>>>> that's what causes the exception in getConnection().
>>>> I've seen quite a few questions about this error, but in the
>>>> archived threads on this mailing list, I haven't found any solution
>>>> to this particular problem... One poster who had the same diagnosis
>>>> mentioned that the problem went away when he got rid of the Context
>>>> element in META-INF/context.xml, but in my case, that file does not
>>>> exist; in fact, the only Context elements I have are the one shown
>>>> above, and the standard one in $TOMCAT_HOME/conf/context.xml.
>>>> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
>>>> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but
>>>> I'm not sure that's relevant because, first of all, DriverManager
>>>> will only use drivers that were loaded by the same class loader as
>>>> itself, and second, the DataSource can't use the driver anyway as
>>>> long as its driverClassName and url properties remain unset.
>>>>
>>>> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
>>>> mysql-connector-java-5.1.5-bin.jar.
>>>>
>>>> I'm stumped... Any thoughts would be much appreciated!
>>>>
>>>> - Thomas
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBC
driver of class '' for connect URL 'null'
Posted by David Smith <dn...@cornell.edu>.
Ok...
The other statistical common thread in this type of issue is a typo or
missing config somewhere along the line in one of these files:
context.xml -- you've provided that and named the resource jdbc/SmmDB
web.xml -- do you have this in your WEB-INF/web.xml:
<resource-ref>
<res-ref-name>jdbc/SmmDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
your java source code -- did you try to fech the DataSource using the
path 'java:/comp/env/jdbc/SmmDB'?
Case is important all the way through this as well. FWIW the Resource
element you posted below looks fine -- good case, valid attributes,
etc., ...
Two things you might want to consider once your db pool starts working
is removing autoReconnect=true from your database url and adding
validationQuery="select 1". Autoreconnect doesn't re-establish a
connection until a request has failed -- makes it virtually useless in a
db pool. validationQuery="select 1" as a Resource attribute causes the
database pool to test the connection with a simple query on borrowing.
--David
Thomas Okken wrote:
> The MySQL driver is in $TOMCAT_HOME/lib, but I don't think that is
> even the issue here -- the real problem is that the DataSource object
> is not initialized, so it doesn't even have the url, driver class
> name, etc.
> This is what my log looks like when I restart Tomcat:
>
> Dec 7, 2007 1:18:50 PM org.apache.catalina.core.AprLifecycleListener init
> INFO: The Apache Tomcat Native library which allows optimal
> performance in production environments was not found on the
> java.library.path:
> /home/tokken/software/jdk1.5.0_11/bin:/home/tokken/apache-tomcat-6.0.14/bin
>
> Dec 7, 2007 1:18:51 PM org.apache.coyote.http11.Http11Protocol init
> INFO: Initializing Coyote HTTP/1.1 on http-8888
> Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.Catalina load
> INFO: Initialization processed in 729 ms
> Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardService start
> INFO: Starting service Catalina
> Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardEngine start
> INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
> Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.HostConfig
> deployDescriptor
> WARNING: A docBase /home/tokken/apache-tomcat-6.0.14/webapps/smm
> inside the host appBase has been specified, and will be ignored
> Dec 7, 2007 1:18:52 PM org.apache.struts.action.ActionServlet initChain
> INFO: Loading chain catalog from
> jar:file:/home/tokken/apache-tomcat-6.0.14/webapps/smm/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
>
> Dec 7, 2007 1:18:53 PM org.apache.catalina.startup.HostConfig deployWAR
> INFO: Deploying web application archive BBYPServer.war
> Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
> INFO: ContextListener: contextInitialized()
> Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
> INFO: SessionListener: contextInitialized()
> Dec 7, 2007 1:18:53 PM org.apache.coyote.http11.Http11Protocol start
> INFO: Starting Coyote HTTP/1.1 on http-8888
> Dec 7, 2007 1:18:53 PM org.apache.jk.common.ChannelSocket init
> INFO: JK: ajp13 listening on /0.0.0.0:8009
> Dec 7, 2007 1:18:54 PM org.apache.jk.server.JkMain start
> INFO: Jk running ID=0 time=0/43 config=null
> Dec 7, 2007 1:18:54 PM org.apache.catalina.startup.Catalina start
> INFO: Server startup in 3005 ms
>
> There is a warning about the docBase attribute (strange; I copied that
> text verbatim from the Tomcat FAQ); if I remove that attribute, the
> warning goes away, but the DataSource remains uninitialized.
>
> - Thomas
>
> David Smith wrote:
>
>> Where did you place your mysql driver jar file? It has to be in
>> tomcat's /lib directory to be visible to tomat's internal code for
>> building the db pool and your webapp. Also did you happen to look at
>> the logs around when your webapp started for any relevant messages?
>>
>> --David
>>
>> Thomas Okken wrote:
>>
>>> Hi all,
>>>
>>> I'm trying to set up a DataSource to manage connections to a MySQL
>>> database, but whenever I call getConnection(), I get this error:
>>>
>>> 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:1150)
>>>
>>> at
>>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>>>
>>> ...
>>> 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:1143)
>>>
>>> ...
>>>
>>>
>>> The datasource is defined in a file called
>>> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context
>>> path is /smm); it looks like this:
>>>
>>> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
>>> crossContext="true">
>>> <Resource name="jdbc/SmmDB" auth="Container"
>>> type="javax.sql.DataSource"
>>> maxActive="100" maxIdle="30" maxWait="10000"
>>> username="wmmdev" password="wmmdev"
>>> driverClassName="com.mysql.jdbc.Driver"
>>>
>>> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
>>>
>>> </Context>
>>>
>>> The fact that the datasource gets created and bound in JNDI tells me
>>> that smm.xml is getting read, but apparently it is not getting
>>> initialized properly; getDriverClassName(), getUrl(), getUsername(),
>>> and getPassword() all return null, and it looks like that's what
>>> causes the exception in getConnection().
>>> I've seen quite a few questions about this error, but in the
>>> archived threads on this mailing list, I haven't found any solution
>>> to this particular problem... One poster who had the same diagnosis
>>> mentioned that the problem went away when he got rid of the Context
>>> element in META-INF/context.xml, but in my case, that file does not
>>> exist; in fact, the only Context elements I have are the one shown
>>> above, and the standard one in $TOMCAT_HOME/conf/context.xml.
>>> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
>>> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but
>>> I'm not sure that's relevant because, first of all, DriverManager
>>> will only use drivers that were loaded by the same class loader as
>>> itself, and second, the DataSource can't use the driver anyway as
>>> long as its driverClassName and url properties remain unset.
>>>
>>> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
>>> mysql-connector-java-5.1.5-bin.jar.
>>>
>>> I'm stumped... Any thoughts would be much appreciated!
>>>
>>> - Thomas
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBC
driver of class '' for connect URL 'null'
Posted by Thomas Okken <to...@ncstech.com>.
The MySQL driver is in $TOMCAT_HOME/lib, but I don't think that is even
the issue here -- the real problem is that the DataSource object is not
initialized, so it doesn't even have the url, driver class name, etc.
This is what my log looks like when I restart Tomcat:
Dec 7, 2007 1:18:50 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance
in production environments was not found on the java.library.path:
/home/tokken/software/jdk1.5.0_11/bin:/home/tokken/apache-tomcat-6.0.14/bin
Dec 7, 2007 1:18:51 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8888
Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 729 ms
Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 7, 2007 1:18:51 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
Dec 7, 2007 1:18:51 PM org.apache.catalina.startup.HostConfig
deployDescriptor
WARNING: A docBase /home/tokken/apache-tomcat-6.0.14/webapps/smm inside
the host appBase has been specified, and will be ignored
Dec 7, 2007 1:18:52 PM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from
jar:file:/home/tokken/apache-tomcat-6.0.14/webapps/smm/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
Dec 7, 2007 1:18:53 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive BBYPServer.war
Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 7, 2007 1:18:53 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Dec 7, 2007 1:18:53 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8888
Dec 7, 2007 1:18:53 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Dec 7, 2007 1:18:54 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/43 config=null
Dec 7, 2007 1:18:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3005 ms
There is a warning about the docBase attribute (strange; I copied that
text verbatim from the Tomcat FAQ); if I remove that attribute, the
warning goes away, but the DataSource remains uninitialized.
- Thomas
David Smith wrote:
> Where did you place your mysql driver jar file? It has to be in
> tomcat's /lib directory to be visible to tomat's internal code for
> building the db pool and your webapp. Also did you happen to look at
> the logs around when your webapp started for any relevant messages?
>
> --David
>
> Thomas Okken wrote:
>
>> Hi all,
>>
>> I'm trying to set up a DataSource to manage connections to a MySQL
>> database, but whenever I call getConnection(), I get this error:
>>
>> 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:1150)
>>
>> at
>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>>
>> ...
>> 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:1143)
>>
>> ...
>>
>>
>> The datasource is defined in a file called
>> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context
>> path is /smm); it looks like this:
>>
>> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
>> crossContext="true">
>> <Resource name="jdbc/SmmDB" auth="Container"
>> type="javax.sql.DataSource"
>> maxActive="100" maxIdle="30" maxWait="10000"
>> username="wmmdev" password="wmmdev"
>> driverClassName="com.mysql.jdbc.Driver"
>>
>> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
>>
>> </Context>
>>
>> The fact that the datasource gets created and bound in JNDI tells me
>> that smm.xml is getting read, but apparently it is not getting
>> initialized properly; getDriverClassName(), getUrl(), getUsername(),
>> and getPassword() all return null, and it looks like that's what
>> causes the exception in getConnection().
>> I've seen quite a few questions about this error, but in the archived
>> threads on this mailing list, I haven't found any solution to this
>> particular problem... One poster who had the same diagnosis mentioned
>> that the problem went away when he got rid of the Context element in
>> META-INF/context.xml, but in my case, that file does not exist; in
>> fact, the only Context elements I have are the one shown above, and
>> the standard one in $TOMCAT_HOME/conf/context.xml.
>> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
>> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but I'm
>> not sure that's relevant because, first of all, DriverManager will
>> only use drivers that were loaded by the same class loader as itself,
>> and second, the DataSource can't use the driver anyway as long as its
>> driverClassName and url properties remain unset.
>>
>> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
>> mysql-connector-java-5.1.5-bin.jar.
>>
>> I'm stumped... Any thoughts would be much appreciated!
>>
>> - Thomas
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBC
driver of class '' for connect URL 'null'
Posted by David Smith <dn...@cornell.edu>.
Where did you place your mysql driver jar file? It has to be in
tomcat's /lib directory to be visible to tomat's internal code for
building the db pool and your webapp. Also did you happen to look at
the logs around when your webapp started for any relevant messages?
--David
Thomas Okken wrote:
> Hi all,
>
> I'm trying to set up a DataSource to manage connections to a MySQL
> database, but whenever I call getConnection(), I get this error:
>
> 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:1150)
>
> at
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>
> ...
> 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:1143)
>
> ...
>
>
> The datasource is defined in a file called
> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context
> path is /smm); it looks like this:
>
> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
> crossContext="true">
> <Resource name="jdbc/SmmDB" auth="Container"
> type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="10000"
> username="wmmdev" password="wmmdev"
> driverClassName="com.mysql.jdbc.Driver"
>
> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
> </Context>
>
> The fact that the datasource gets created and bound in JNDI tells me
> that smm.xml is getting read, but apparently it is not getting
> initialized properly; getDriverClassName(), getUrl(), getUsername(),
> and getPassword() all return null, and it looks like that's what
> causes the exception in getConnection().
> I've seen quite a few questions about this error, but in the archived
> threads on this mailing list, I haven't found any solution to this
> particular problem... One poster who had the same diagnosis mentioned
> that the problem went away when he got rid of the Context element in
> META-INF/context.xml, but in my case, that file does not exist; in
> fact, the only Context elements I have are the one shown above, and
> the standard one in $TOMCAT_HOME/conf/context.xml.
> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but I'm
> not sure that's relevant because, first of all, DriverManager will
> only use drivers that were loaded by the same class loader as itself,
> and second, the DataSource can't use the driver anyway as long as its
> driverClassName and url properties remain unset.
>
> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
> mysql-connector-java-5.1.5-bin.jar.
>
> I'm stumped... Any thoughts would be much appreciated!
>
> - Thomas
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DataSource created but not initialized => Cannot create JDBC
driver of class '' for connect URL 'null'
Posted by Thomas Okken <to...@ncstech.com>.
Hi Martin,
My MySQL server is alive and well; I can connect to it using the same
parameters, using a JDBC-based database browser.
I didn't know about autoReconnect being deprecated; it still appears to
be supported, but I see that the MySQL 5.0 reference manual recommends
cranking up the server's wait_timeout instead. I'll do that and get rid
of the autoReconnect; I don't want the server to ever drop idle
connections anyway.
Unfortunately, this doesn't fix the problem of the DataSource not
getting initialized... but thanks anyway! :-)
- Thomas
mgainty@hotmail.com wrote:
> Hi Tom
>
> here is my jdbc.properties which is used for petstore access to MySQL tables
> #jdbc.driverClassName=org.hsqldb.jdbcDriver
> jdbc.driverClassName=com.mysql.jdbc.Driver
> #jdbc.url=jdbc:hsqldb:hsql://localhost:9001
> jdbc.url=jdbc:mysql://localhost:3306/petclinic
> jdbc.username=fu
> jdbc.password=bar
>
> your URL is quite similar and constructed correctly
> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/
>
> so I would check to see if there is a MySQL Listening on
> ss1-.research.att.com e.g.
> login to ss-1.research.att.com
> netstat -a | grep 3306
>
> the newer versions of mySQL (specifically 4 and 5) dont support deprecated
> autoReconnect attribute
> http://forums.mysql.com/read.php?39,32231,32231
>
> HTH
> Martin-
> ----- Original Message -----
> Wrom: UZXUWLSZLKBRNVWWCUFPEGAUTFJMVRESKPN
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Friday, December 07, 2007 12:14 PM
> Subject: DataSource created but not initialized => Cannot create JDBC driver
> of class '' for connect URL 'null'
>
>
>
>> Hi all,
>>
>> I'm trying to set up a DataSource to manage connections to a MySQL
>> database, but whenever I call getConnection(), I get this error:
>>
>> 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:1150)
>
>> at
>>
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.ja
> va:880)
>
>> ...
>> 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:1143)
>
>> ...
>>
>>
>> The datasource is defined in a file called
>> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context path
>> is /smm); it looks like this:
>>
>> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
>> crossContext="true">
>> <Resource name="jdbc/SmmDB" auth="Container"
>>
> type="javax.sql.DataSource"
>
>> maxActive="100" maxIdle="30" maxWait="10000"
>> username="wmmdev" password="wmmdev"
>> driverClassName="com.mysql.jdbc.Driver"
>>
>> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
>> </Context>
>>
>> The fact that the datasource gets created and bound in JNDI tells me
>> that smm.xml is getting read, but apparently it is not getting
>> initialized properly; getDriverClassName(), getUrl(), getUsername(), and
>> getPassword() all return null, and it looks like that's what causes the
>> exception in getConnection().
>> I've seen quite a few questions about this error, but in the archived
>> threads on this mailing list, I haven't found any solution to this
>> particular problem... One poster who had the same diagnosis mentioned
>> that the problem went away when he got rid of the Context element in
>> META-INF/context.xml, but in my case, that file does not exist; in fact,
>> the only Context elements I have are the one shown above, and the
>> standard one in $TOMCAT_HOME/conf/context.xml.
>> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
>> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but I'm
>> not sure that's relevant because, first of all, DriverManager will only
>> use drivers that were loaded by the same class loader as itself, and
>> second, the DataSource can't use the driver anyway as long as its
>> driverClassName and url properties remain unset.
>>
>> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
>> mysql-connector-java-5.1.5-bin.jar.
>>
>> I'm stumped... Any thoughts would be much appreciated!
>>
>> - Thomas
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: DataSource created but not initialized => Cannot create JDBC driver of class '' for connect URL 'null'
Posted by mg...@hotmail.com.
Hi Tom
here is my jdbc.properties which is used for petstore access to MySQL tables
#jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.driverClassName=com.mysql.jdbc.Driver
#jdbc.url=jdbc:hsqldb:hsql://localhost:9001
jdbc.url=jdbc:mysql://localhost:3306/petclinic
jdbc.username=fu
jdbc.password=bar
your URL is quite similar and constructed correctly
url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/
so I would check to see if there is a MySQL Listening on
ss1-.research.att.com e.g.
login to ss-1.research.att.com
netstat -a | grep 3306
the newer versions of mySQL (specifically 4 and 5) dont support deprecated
autoReconnect attribute
http://forums.mysql.com/read.php?39,32231,32231
HTH
Martin-
----- Original Message -----
Wrom: UZXUWLSZLKBRNVWWCUFPEGAUTFJMVRESKPN
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Friday, December 07, 2007 12:14 PM
Subject: DataSource created but not initialized => Cannot create JDBC driver
of class '' for connect URL 'null'
> Hi all,
>
> I'm trying to set up a DataSource to manage connections to a MySQL
> database, but whenever I call getConnection(), I get this error:
>
> 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:1150)
> at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.ja
va:880)
> ...
> 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:1143)
> ...
>
>
> The datasource is defined in a file called
> $TOMCAT_HOME/conf/Catalina/localhost/smm.xml (the web app's context path
> is /smm); it looks like this:
>
> <Context path="/smm" docBase="smm" debug="5" reloadable="true"
> crossContext="true">
> <Resource name="jdbc/SmmDB" auth="Container"
type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="10000"
> username="wmmdev" password="wmmdev"
> driverClassName="com.mysql.jdbc.Driver"
>
> url="jdbc:mysql://ss-1.research.att.com:3306/wmmdev?autoReconnect=true"/>
> </Context>
>
> The fact that the datasource gets created and bound in JNDI tells me
> that smm.xml is getting read, but apparently it is not getting
> initialized properly; getDriverClassName(), getUrl(), getUsername(), and
> getPassword() all return null, and it looks like that's what causes the
> exception in getConnection().
> I've seen quite a few questions about this error, but in the archived
> threads on this mailing list, I haven't found any solution to this
> particular problem... One poster who had the same diagnosis mentioned
> that the problem went away when he got rid of the Context element in
> META-INF/context.xml, but in my case, that file does not exist; in fact,
> the only Context elements I have are the one shown above, and the
> standard one in $TOMCAT_HOME/conf/context.xml.
> The MySQL JDBC driver is in $TOMCAT_HOME/lib, and when I do
> Class.forName("com.mysql.jdbc.Driver") in a JSP, it succeeds, but I'm
> not sure that's relevant because, first of all, DriverManager will only
> use drivers that were loaded by the same class loader as itself, and
> second, the DataSource can't use the driver anyway as long as its
> driverClassName and url properties remain unset.
>
> I'm using Tomcat 6.0.14, JDK 1.5.0_11, MySQL 5.0.45, and
> mysql-connector-java-5.1.5-bin.jar.
>
> I'm stumped... Any thoughts would be much appreciated!
>
> - Thomas
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org