Skip to content

Duplicate Classes while importing clickhouse-jdbc #2474

In review

Description

@akhalifeh79

Description

While importing in maven project only this dependency

com.clickhouse
clickhouse-jdbc
0.7.2
http

I receive the following warnings:

[WARNING] Found duplicate and different classes in [com.clickhouse:clickhouse-data:0.7.2, com.clickhouse:clickhouse-jdbc:0.7.2:jar:http, com.clickhouse:jdbc-v2:0.7.2]:
[WARNING] com.clickhouse.data.stream.Lz4InputStream
[WARNING] com.clickhouse.data.stream.Lz4OutputStream

Expected Behaviour

No duplicated classes must be found

Activity

  1. github-actions commented on Jun 28, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

  2. added this to the 0.12.0 milestone on Jul 22, 2026
  3. added
    planned_work
    on Nov 18, 2026
  4. chernser commented on Nov 23, 2026

    @chernser
    Contributor

    @polyglotAI-bot
    please verify this is not the case for the latest release

  5. polyglotAI-bot commented on Nov 24, 2026

    @polyglotAI-bot
    Collaborator

    The warning does not occur with the standard artifact in 0.11.2 (the latest release). It still occurs with the shaded artifacts: the all and all-dependencies classifiers, and com.clickhouse:clickhouse-jdbc-all.

    The http classifier from the report is not published since 0.9.0. The packaging on main did not change after 0.11.2.

    Test: a Maven project with one dependency, mvn org.basepom.maven:duplicate-finder-maven-plugin:2.0.1:check, Maven 3.9.15, JDK 17.

    Dependency Result
    clickhouse-jdbc:0.7.2, classifier http Same warning as the report
    clickhouse-jdbc:0.11.2, no classifier No duplicates. A SELECT through JDBC works (server 26.10)
    clickhouse-jdbc:0.11.2, classifier all Duplicate and different classes
    clickhouse-jdbc:0.11.2, classifier all-dependencies Duplicate and different classes
    clickhouse-jdbc-all:0.11.2 Duplicate and different classes
    clickhouse-jdbc:0.11.2, classifier all, exclusion *:*, plus slf4j-api No duplicates. A SELECT through JDBC works

    Output for classifier all (one of four groups):

    [WARNING] Found duplicate and different classes in [com.clickhouse:clickhouse-data:0.11.2, com.clickhouse:clickhouse-jdbc:0.11.2:jar:all]:
    [WARNING]   com.clickhouse.data.UnloadableClassLoader
    [WARNING]   com.clickhouse.data.format.JsonStreamUtils
    [WARNING]   com.clickhouse.data.stream.Lz4InputStream
    [WARNING]   com.clickhouse.data.stream.Lz4OutputStream
    [WARNING]   com.clickhouse.data.value.ClickHouseBitmap
    

    The other groups are with client-v2 (11 classes, for example com.clickhouse.client.api.Client), jdbc-v2 (9 classes, for example com.clickhouse.jdbc.ConnectionImpl) and clickhouse-http-client (2 classes).

    Cause: an artifact with a classifier uses the POM of the main artifact. The clickhouse-jdbc 0.11.2 POM declares clickhouse-data, clickhouse-client, clickhouse-http-client, client-v2 and jdbc-v2 as compile dependencies. Thus Maven adds these jars next to the all jar, which already contains their classes. The clickhouse-jdbc-all 0.11.2 POM declares the same modules as direct dependencies. The copies are different because the shaded copy refers to relocated packages: Lz4InputStream in the all jar uses com.clickhouse.client.internal.net.jpountz.lz4.LZ4Factory, and the copy in clickhouse-data uses net.jpountz.lz4.LZ4Factory. The JVM loads the copy that is first on the classpath.

    Workaround for the all classifier: exclude all transitive dependencies, and add slf4j-api, because the all jar does not contain SLF4J. Without slf4j-api, DriverManager.getConnection fails with No suitable driver found (cause: NoClassDefFoundError: org/slf4j/LoggerFactory).

    <dependency>
        <groupId>com.clickhouse</groupId>
        <artifactId>clickhouse-jdbc</artifactId>
        <version>0.11.2</version>
        <classifier>all</classifier>
        <exclusions>
            <exclusion>
                <groupId>*</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.7</version>
    </dependency>

    Open: the shaded artifacts still have the problem. docs/integration-jdbc.md describes the all artifact as "a single self-contained archive" and does not mention the exclusions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:packagingbugplanned_work

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions