| Author |
Cannot create JDBC driver of class '' for connect URL 'null'
|
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
Hi
I have a problem to work with JPA and Tomcat 6
I'm trying to fetch data from the datasource but it shows the following error Cannot create JDBC driver of class '' for connect URL 'null'
I followed the documentation http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
my settings
persistence.xml
context.xml
web.xlm
I'm using version 6.0.35
I looked at the solutions of problems identical, but the result always seems to be this setting
tks
|
 |
Kiril Nugmanov
Ranch Hand
Joined: Jul 09, 2008
Posts: 42
|
|
Hi,
Concerning Your configuration:
Your application uses data source that called jdbc/sabit - follows from web.xmlYour web container has only jdbc/postgres data source - follows from context.xmlYour application for persistence uses java:/comp/env/jdbc/sabit data source - follows from persistence.xml
Conclusion:
Change context.xml so that name would meet the name from web.xml
Note: I'm not really sure but in Tomcat container You could define persistence data source without java:/comp/env/.
Also be sure that your connection drivers are loaded with web container (driver jars are in lib directory).
Strange: You in persistence.xml define Your connection as org.hibernate.dialect.Oracle10gDialect but in context.xml using org.postgresql.Driver. Check once again Your configuration.
|
SCJP5, SCWCD5, SCBCD5, OCPJWSD5, OCMJEA 5
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 12513
|
|
The most common cause of this really annoying error is something miscoded on the Tomcat Resource definition. Usually the URL, since a miscoded class name results in a ClassNotFoundException, and invalid userid/password generally results in a login rejection.
It's definitely not right that the Resource is registered under (java:comp/env/)jdbc/posgres, but the webapp is attempting to look up java:comp/env/jdcb/sabit. Although ordinarily attempting to look up an undefined name via JNDI would result in a NamingException, so I wonder if there isn't another Resource definition you didn't tell us about.
As for having the "java:comp/env" part of the directory path be optional, Tomcat itself merely provides the app with a JNDI registry. However, the client JPA code may be capable of automatically supplying the fixed part of the directory path. Either it or Spring can, I know, but it's been a while since I looked at it. It's safer to use the full (absolute) JNDI path, however.
|
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
Thanks for the reply.
Because of these differences, with remaking a true example of documentation.
code
context.xml
web.xml
I put the complete exception
Strange to see a NullPointer
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 12513
|
|
# Caused by: java.lang.NullPointerException
# at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
# at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
# at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
# at java.sql.DriverManager.getDriver(DriverManager.java:253)
# at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
Check to make sure that your Oracle JDBC driver jar is present in the Tomcat server's "lib" directory. DO NOT include this jar in the WAR itself!
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
I put the ojdbc6.jar in
apache-tomcat-6.0.35\lib
and
apache-tomcat-6.0.35\common\lib
in my VM arguments
-Dcatalina.home="C:\java\apache-tomcat-6.0.35"
verify my war and not have JDBC driver
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 12513
|
|
|
There shouldn't be a common/lib directory in Tomcat 6. The 3 library directories that Tomcat 5 used were removed in favor of a single lib directory.
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
without cthe problem continues..
i put common/lib for tests.
will be something in the context in my war?
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18370
|
|
|
Did anyone else notice that the ODBC driver is used and not the Oracle driver?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
What could be happening?
I have no idea
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
|
How change this ODBC ?
|
 |
Paulo Bianchin
Greenhorn
Joined: Jan 16, 2012
Posts: 11
|
|
The problem is in deployment via eclipse. Doing it direct in tomcat works.
Thanks for all answers.
|
 |
 |
|
|
subject: Cannot create JDBC driver of class '' for connect URL 'null'
|
|
|