clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

java.lang.NoSuchFieldError: Companion. When my project reference okhttp3.

Open xywendz opened this issue 3 years ago • 1 comments

youdu图片20230215121857

My project refeenced okhttp3, version 4.7.2. Keep reporting errors when using clickhouse-jdbc, "java.lang.NoSuchFieldError: Companion" 。During the inspection, the io.rpc.jar package of clickhouse was found and the okio code was packaged, which led to version compatibility problems.

Solution method,exclude grpc and io.grpc package.

    <dependency>
            <groupId>com.clickhouse</groupId>
            <artifactId>clickhouse-jdbc</artifactId>
            <version>0.4.0</version>
            <classifier>http</classifier>
            <exclusions>
                <exclusion>
                    <groupId>com.clickhouse</groupId>
                    <artifactId>io.grpc</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.clickhouse</groupId>
                    <artifactId>clickhouse-grpc-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

xywendz avatar Feb 15 '23 04:02 xywendz

Sorry for the inconvenience @xywendz. I'll make all dependencies in clickhouse-jdbc optional, so that nobody has to do this ever again.

zhicwu avatar Feb 16 '23 01:02 zhicwu