This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Cannot create JDBC driver of class '' for connect URL 'null' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Cannot create JDBC driver of class Watch "Cannot create JDBC driver of class New topic
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.xml
  • Your web container has only jdbc/postgres data source - follows from context.xml
  • Your 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: 15959
        
      19

    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.


    Customer surveys are for companies who didn't pay proper attention to begin with.
    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: 15959
        
      19


    # 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: 15959
        
      19

    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
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19654
        
      18

    Did anyone else notice that the ODBC driver is used and not the Oracle driver?


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    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.
    Luiz Veronesi
    Greenhorn

    Joined: Jan 31, 2013
    Posts: 1
    Hey dude, I was having the same issue. The problem is at server configuration inside Eclipse.

    You must check the option "Use Tomcat Installation (takes control of Tomcat installation)" at Server Locations configuration on your Tomcat Server instance.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Cannot create JDBC driver of class '' for connect URL 'null'
     
    Similar Threads
    SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' (Hibernate + Seam)
    Can't get connection from DataSource object
    Jboss Error
    jpa, datasource and tomcat
    Connecting to database in Tomcat 5.5