Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver


Hello, I have searched for previous posts concerning similar issue and can confirm that build/distributions/ has in its lib directory postgresql-42.7.3.jar.  Other dependencies are loaded just fine. I run IDEA via gradle runIde task. Are there any known limitations on loading jdbc drivers or class loading intricacies in general? I try access database during autocompletion from CompletionContributor to pull live data for autocompletion in real-time, I tried run it directly and via ApplicationUtil.runWithCheckCanceled as recommended in documentation.


SEVERE - #c.i.c.c.CompletionProgressIndicator - null
at com.plugin.completion.MyCompletionContributor$MyCompletionProviders$MyProvider.addCompletions
Caused by: java.lang.IllegalStateException: Could not load JDBC driver class [org.postgresql.Driver]
at com.plugin.database.Db.<clinit>
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver


Initially I tried org.springframework.jdbc.datasource.DriverManagerDataSource from org.springframework:spring-jdbc.

It complained about Caused by: java.lang.IllegalStateException: Could not load JDBC driver class [org.postgresql.Driver].

Afterwards I tried HikariDataSource and PGSimpleDataSource both work fine.

Spring implementation kept failing for the same reason (ClassNotFoundException) even when 1) I created HikariDataSource 2) used it to retrieve data from DB and 3) attempted to create and use Spring implementation. For some reason it boiled out with ClassNotFoundException. Probably has smth to do with how Spring loads jdbc driver class. Wanted to let you know, in case someone encounters similar issue (try other DataSource implementations) or maybe even it could be addressed by JB team.