Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver'

I'm having trouble to migrate from an oracle db web-app context to a postgresql db web-app context.

I'm having a simple java spring-mvc web-app with flyway to init the database process and hibernate to manage objects. This web-app was initialiy think to use a oracle database and I'm trying to use a postgresql base instead, but I'm pretty new with this base and not confortable with the declaration of the datasource. May be you will find what's wrong.

I'm using tomcat apache server (v6) within eclipse plugin to debug my webapp.

When I'm trying to run my web-app on my server, the server failed to start with this log :

11:23:57.903 [main] INFO  o.h.tool.hbm2ddl.SchemaUpdate - HHH000228: Running hbm2ddl schema update
11:23:57.903 [main] INFO  o.h.tool.hbm2ddl.SchemaUpdate - HHH000102: Fetching database metadata
11:23:57.903 [main] ERROR o.h.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136) ~[tomcat-dbcp.jar:na]
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) ~[tomcat-dbcp.jar:na]
[...]
Caused by: java.lang.UnsupportedClassVersionError: org/postgresql/Driver : Unsupported major.minor version 51.0

I've add the driver to my pom.xml

   <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1200-jdbc41</version>
    </dependency>

and made the

   mvn eclipse:eclipse 

I'm using a datasource declared in my META-INF directory :

   <Context>
      <Resource name="jdbc/BlankAppDataSource"
        auth="Container"
        type="javax.sql.DataSource"
        username="postgres"
        password="postgres"
        driverClassName="org.postgresql.Driver"
        url="jdbc:postgresql://localhost:5432/my_schema" 
/>

I've even added the driver .jar to my tomcat lib directory (CATALINA_HOME/lib).

Thanks by advance.

Regards, Romain.

like image 746
RVA Avatar asked Jul 22 '26 08:07

RVA


1 Answers

I had the same problem and in my case, i just inserted the lib "postgresql-8.0-314jdbc3.jar" in the "apache-tomcat-6.0.44/lib" folder and it ran perfectly.

I'm using the JDK 1.8.0_60 in Tomcat Server Runtime Environment.

like image 190
Leonardo Nogueira Avatar answered Jul 24 '26 05:07

Leonardo Nogueira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!