JDBC Connection fails with "Driver class 'org.slf4j.LoggerFactory' not found."
Describe the bug
In IntelliJ ultimate updated my Clickhouse Datasource from driver version 0.8.2 to 0.8.3 On "Test Connection" the connection fails with this error:
DBMS: ClickHouse (ver. 25.3.2.39) Case sensitivity: plain=exact, delimited=exact Driver: ClickHouse JDBC Driver (ver. 0.6.3 (revision: a6a8a22), JDBC4.2) Driver class 'org.slf4j.LoggerFactory' not found.
Steps to reproduce
- update the Driver class to version 0.8.2
Hi @frankwese - could you please try the shaded-all jar?
We're going to revisit some of the packaging, but in the meanwhile that should resolve this for you.
Good day, @frankwese!
The problem here is that org.slf4j.LoggerFactory is part of slf4j-api artifact.
If we include it as is inside the package it will conflict with application instance of same artifact what is not good because library should have flexible dependencies.
If we include slf4j-api as shaded library it will cause change of FCN of all API classes and it will be hard to use it with other logging backends so logging will be broken for our library.
Solution here may be having several versions of packaging
- jar with declared dependencies works when application want a full control over dependencies
- jar + all required dependencies (not shaded) - that would work for your case when application doesn't promote own dependencies
- jar + some required dependencies (shaded) - that would work for application using different similar client libraries. However there is still a problem with common part libraries like logging, metrics, format processing libraries.
@frankwese This worked with shaded-all (rather than just -all) but leaving this open as we (the team) should discuss packaging
Just for notes: shaded-all helps to resolve the issue.
However 0.8.2-all has the same problem.
Here is application log:
2025-06-03 14:29:20,441 [ 787636] WARN - #c.i.e.r.RemoteProcessSupport - Remote process stderr:java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
2025-06-03 14:29:20,441 [ 787636] WARN - #c.i.e.r.RemoteProcessSupport - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
2025-06-03 14:29:20,441 [ 787636] WARN - #c.i.e.r.RemoteProcessSupport - Remote process stderr: at com.clickhouse.client.internal.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.<clinit>(PoolingHttpClientConnectionManager.java:108)
2025-06-03 14:29:20,441 [ 787636] WARN - #c.i.e.r.RemoteProcessSupport - at com.clickhouse.client.internal.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.<clinit>(PoolingHttpClientConnectionManager.java:108)
2025-06-03 14:29:20,441 [ 787636] WARN - #c.i.e.r.RemoteProcessSupport - Remote process stderr: at com.clickhouse.client.http.ApacheHttpConnectionImpl.getDefaultUserAgent(ApacheHttpConnectionImpl.java:226)
Adding slf4j-api to the classpath solves the issue:
Why we may not include into -all:
- This classifier is mainly used by applications that provide own version of
slf4j-apiand logging backend so we do not want to enforce our version. - If we shade
slf4j-apithen it will be moved to another package and no other logging backend may use it.
I'm seeing the same issue when loading the driver into the Splunk DB Connect App as detailed here: https://clickhouse.com/docs/integrations/splunk I was able to load the clickhouse-jdbc-0.8.6-shaded-all.jar release, but I'm afraid of falling behind in future releases as I personally could not find a way to force Splunk's DB Connect App to directly load the slf4j-api JAR file. Maybe somebody knows a way to do this or could share some compilation instructions for folks to include it themselves?
Good day, @burcheja ! we are planning to create another bundles for such cases that will include everything even such dependencies as API libs.
Do you use on-prem Splunk installation and can you install drivers?
Thanks!
Hello @chernser, thanks for the quick response, it's greatly appreciated. That sounds great! I am using an on-premise Splunk installation and can install drivers.
We have added clickhouse-jdbc-*-all-dependencies.jar to assets of a release. since 0.9.4.