• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot create JDBC driver of class '' for connect URL 'null'

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

     
    Saloon Keeper
    Posts: 27764
    196
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Paulo Bianchin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27764
    196
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    # 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
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    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
    Posts: 27764
    196
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    without cthe problem continues..


    i put common/lib for tests.


    will be something in the context in my war?

     
    Sheriff
    Posts: 22783
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Did anyone else notice that the ODBC driver is used and not the Oracle driver?
     
    Paulo Bianchin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    What could be happening?

    I have no idea
     
    Paulo Bianchin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    How change this ODBC ?
     
    Paulo Bianchin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The problem is in deployment via eclipse. Doing it direct in tomcat works.

    Thanks for all answers.
     
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic