2022-08-23

java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`

Error occurs when instantiating a client

    InfluxDBClientReactive influxDBClient = InfluxDBClientReactiveFactory.create(
            influxConf.url(),
            influxConf.username(),
            influxConf.password().toCharArray());

dependency is excluded from quarkus-bom

implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") {
    exclude group: "com.squareup.okhttp3", module: "okhttp"
}
implementation "com.influxdb:influxdb-client-reactive:6.4.0" 

otherwise (3.x.x) is forced and would cause

'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)

at the same line.

trace:

Companion
java.lang.NoSuchFieldError: Companion
    at okhttp3.internal.Util.<clinit>(Util.kt:70)
    at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239)
    at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1634)
    at okhttp3.HttpUrl$Companion.parse(HttpUrl.kt:1643)
    at okhttp3.HttpUrl.parse(HttpUrl.kt)
    at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.<init>(InfluxDBClientOptions.java:689)
    at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.<init>(InfluxDBClientOptions.java:681)
    at com.influxdb.client.InfluxDBClientOptions$Builder.connectionString(InfluxDBClientOptions.java:504)
    at com.influxdb.client.InfluxDBClientOptions$Builder.url(InfluxDBClientOptions.java:288)
    at com.influxdb.client.reactive.InfluxDBClientReactiveFactory.create(InfluxDBClientReactiveFactory.java:105)


No comments:

Post a Comment