Cannot create JDBC driver of class '' for connect URL 'null'-Caused by: jav
843859May 20 2010 — edited Nov 20 2014Hi Oracle/Sun JDBC forum,
I read this topic http://forums.sun.com/thread.jspa?threadID=5369213 without reaching a solution in my case.
I get the following Exception logged by Catalina when retrieving the DataSource.
My own logging verifies that a DataSource object that is not null was returned
Servlet Logged
Context context = new InitialContext();
ds = (DataSource) context.lookup("java:comp/env/jdbc/RMDB");
if (ds != null) {
// Print message below
conn = ds.getConnection(); // causes NullPointerException
}
Message: Found a DataSource for lookup string 'java:comp/env/jdbc/RMDB'!
Error logged:
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)
...
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:279)
The main problem seems to me that either tomcat does not find the connector driver class or the configuration regarding the data source is incorrect.
A third alternative would be that tomcat is not allowed to read the connector jar file due to permissions. (SELINUX has been disabled)
I have the application running on a windows XP machine for testing purposes and would deploy on the CENTOS 5.4 purposes as soon it works there as well.
Access via Sqlyog from windows machine to Linux MySQL works and grants have been given to appropriate users.
The user has been granted all and exist in the version and the same password configured
user@localhost.localdomain
user@localhost
user@%
Tomcat6 works fine and serves simple html and other files from this application.
The mysql connector is stored here:
(I tried with the lib first and then put it in the other places too without success)
/usr/share/java/mysql-connector-java-5.1.5-bin.jar
/usr/share/java/tomcat6/mysql-connector-java-5.1.5-bin.jar
/usr/share/tomcat6/lib/mysql-connector-java-5.1.5-bin.jar
application context.xml
<Resource name="jdbc/RMDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="user"
password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/rmdb" removeAbandoned="true"
removeAbandonedTimeout="60" logAbandoned="true" />
application web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/RMDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I would be grateful on resolving this issue.
Thank you very much,
Cicusknight
Edited by: Cicus on May 20, 2010 1:34 PM