0

I'm working on IntelliJ with Tomcat and postgresql but I have this problem when I run my application:

java.lang.ClassNotFoundException: org.postgres.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264) and so on..

I have already put the JAR file in tomcat/lib but nothing changed. Thanks for helping me.

wero
  • 32,544
  • 3
  • 59
  • 84
verobro20
  • 3
  • 2
  • 2
    Assuming you have your app in `WEB-INF/classes`, putting the driver in `WEB-INF/lib` should work – Ishnark May 11 '17 at 15:23
  • You don't need to use `Class.forName(driverName)` if you're using a modern JDBC driver (recent download). This might solve your problem on it's own. – SnakeDoc May 11 '17 at 16:31
  • @Ishnark You never ever put a DB driver to `WEB-INF/lib`. – Michael-O May 11 '17 at 19:26
  • @Michael-O After reading this (http://stackoverflow.com/questions/13161747/where-do-i-have-to-place-the-jdbc-driver-for-tomcats-connection-pool) I see what the issue is with that approach. Thanks for letting me know. – Ishnark May 12 '17 at 14:51

2 Answers2

2

You misspelled/shortened the qualified name of the PostgreSQL JDBC driver. The correct name is

org.postgresql.Driver 
wero
  • 32,544
  • 3
  • 59
  • 84
1

Make sure JDBC jar is added to the module dependencies: http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html.