Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The version of okhttp3 is not compatible #290

Closed
chb1828 opened this issue Dec 16, 2021 · 8 comments · Fixed by #297
Closed

The version of okhttp3 is not compatible #290

chb1828 opened this issue Dec 16, 2021 · 8 comments · Fixed by #297
Labels
bug Something isn't working
Milestone

Comments

@chb1828
Copy link

chb1828 commented Dec 16, 2021

influxdb-client-version : 4.0.0

It won't run because the version of that dependency doesn't match.
The error log is as below.

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.influxdb.client.internal.AuthenticateInterceptor.initToken(AuthenticateInterceptor.java:122)

The following method did not exist:

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

The calling method's class, com.influxdb.client.internal.AuthenticateInterceptor, was loaded from the following location:

    jar:file:/C:/.../gradle/caches/modules-2/files-2.1/com.influxdb/influxdb-client-java/4.0.0/c9b3a066f15c0bd8799936c623a8d096c86c64fd/influxdb-client-java-4.0.0.jar!/com/influxdb/client/internal/AuthenticateInterceptor.class

The called method's class, okhttp3.RequestBody, is available from the following locations:

    jar:file:/C:/.../.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.14.9/3e6d101343c7ea687cd593e4990f73b25c878383/okhttp-3.14.9.jar!/okhttp3/RequestBody.class

The called method's class hierarchy was loaded from the following locations:

    okhttp3.RequestBody: file:/C:/.../.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.14.9/3e6d101343c7ea687cd593e4990f73b25c878383/okhttp-3.14.9.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes com.influxdb.client.internal.AuthenticateInterceptor and okhttp3.RequestBody

Disconnected from the target VM, address: '127.0.0.1:62083', transport: 'socket'

Process finished with exit code 1

So I changed okhttp version 3.14 to version 4.9.3

build.gradle

    implementation ("com.influxdb:influxdb-client-reactive:${influxVersion}") {
        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
        exclude group: 'com.squareup.okhttp3', module: 'logging-interceptor'
    }
    implementation "com.squareup.okhttp3:okhttp:4.9.3"
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
@bednar
Copy link
Contributor

bednar commented Jan 7, 2022

Hi @chb1828,

thanks for using our client.

The clients depends on okhttp:4.7.2:

<dependency.okhttp3.version>4.7.2</dependency.okhttp3.version>

You have to use version compatible with 4.7.2.

Regards

@bednar bednar added the wontfix This will not be worked on label Jan 7, 2022
@chb1828
Copy link
Author

chb1828 commented Jan 14, 2022

@bednar
Yes, but the okhttp version used by the above dependency is 3.14.9 .
It looks like you need to change the okhttp3 version of influxdb-client-reactive.
am i doing something wrong?

@bednar
Copy link
Contributor

bednar commented Jan 14, 2022

Hi @chb1828,

it looks like difference behaviour of resolving transient dependencies in Gradle and Maven. The Maven correctly resolve okhttp as 4.7.2:

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------< com.influxdb:influxdb-client-reactive >----------------
[INFO] Building The RxJava InfluxDB 2.0 Client 4.1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from bonitoo-repository: https://apitea.com/nexus/content/repositories/bonitoo-snapshot/com/influxdb/influxdb-client-java/4.1.0-SNAPSHOT/maven-metadata.xml
Downloading from bonitoo-repository: https://apitea.com/nexus/content/repositories/bonitoo-snapshot/com/influxdb/influxdb-client/4.1.0-SNAPSHOT/maven-metadata.xml
Downloading from bonitoo-repository: https://apitea.com/nexus/content/repositories/bonitoo-snapshot/com/influxdb/influxdb-client-core/4.1.0-SNAPSHOT/maven-metadata.xml
Downloading from bonitoo-repository: https://apitea.com/nexus/content/repositories/bonitoo-snapshot/com/influxdb/influxdb-client-utils/4.1.0-SNAPSHOT/maven-metadata.xml
Downloading from bonitoo-repository: https://apitea.com/nexus/content/repositories/bonitoo-snapshot/com/influxdb/influxdb-client-test/4.1.0-SNAPSHOT/maven-metadata.xml
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ influxdb-client-reactive ---
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
[INFO] com.influxdb:influxdb-client-reactive:jar:4.1.0-SNAPSHOT
[INFO] +- com.influxdb:influxdb-client-java:jar:4.1.0-SNAPSHOT:compile
[INFO] |  +- com.influxdb:influxdb-client-core:jar:4.1.0-SNAPSHOT:compile
[INFO] |  |  +- com.influxdb:influxdb-client-utils:jar:4.1.0-SNAPSHOT:compile
[INFO] |  |  |  \- (com.google.code.findbugs:jsr305:jar:3.0.2:compile - omitted for duplicate)
[INFO] |  |  +- (com.squareup.retrofit2:retrofit:jar:2.9.0:compile - omitted for duplicate)
[INFO] |  |  +- com.squareup.okhttp3:okhttp:jar:4.7.2:compile
[INFO] |  |  |  +- (com.squareup.okio:okio:jar:2.6.0:compile - omitted for duplicate)
[INFO] |  |  |  \- (org.jetbrains.kotlin:kotlin-stdlib:jar:1.5.10:compile - version managed from 1.3.70; omitted for duplicate)
[INFO] |  |  +- com.squareup.okhttp3:logging-interceptor:jar:4.7.2:compile
[INFO] |  |  |  \- (com.squareup.okhttp3:okhttp:jar:4.7.2:compile - version managed from 3.14.9; omitted for duplicate)
[INFO] |  |  +- org.apache.commons:commons-csv:jar:1.8:compile
[INFO] |  |  +- com.google.code.gson:gson:jar:2.8.8:compile
[INFO] |  |  \- (com.google.code.findbugs:jsr305:jar:3.0.2:compile - omitted for duplicate)
[INFO] |  +- io.reactivex.rxjava2:rxjava:jar:2.2.19:compile
[INFO] |  |  \- (org.reactivestreams:reactive-streams:jar:1.0.3:compile - omitted for duplicate)
[INFO] |  +- com.squareup.okio:okio:jar:2.6.0:compile
[INFO] |  |  +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.5.10:compile
[INFO] |  |  |  +- org.jetbrains:annotations:jar:13.0:compile
[INFO] |  |  |  \- (org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.5.10:compile - omitted for conflict with 1.3.70)
[INFO] |  |  \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.70:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.6.1:compile
[INFO] |  +- io.gsonfire:gson-fire:jar:1.8.4:compile
[INFO] |  |  \- (com.google.code.gson:gson:jar:2.8.8:compile - version managed from 2.8.6; omitted for duplicate)
[INFO] |  +- com.squareup.retrofit2:converter-scalars:jar:2.9.0:compile
[INFO] |  |  \- (com.squareup.retrofit2:retrofit:jar:2.9.0:compile - omitted for duplicate)
[INFO] |  +- com.squareup.retrofit2:converter-gson:jar:2.9.0:compile
[INFO] |  |  +- (com.squareup.retrofit2:retrofit:jar:2.9.0:compile - omitted for duplicate)
[INFO] |  |  \- (com.google.code.gson:gson:jar:2.8.8:compile - version managed from 2.8.5; omitted for duplicate)
[INFO] |  \- (com.google.code.findbugs:jsr305:jar:3.0.2:compile - omitted for duplicate)
[INFO] +- com.squareup.retrofit2:adapter-rxjava2:jar:2.9.0:compile
[INFO] |  +- com.squareup.retrofit2:retrofit:jar:2.9.0:compile
[INFO] |  |  \- (com.squareup.okhttp3:okhttp:jar:4.7.2:compile - version managed from 3.14.9; omitted for duplicate)
[INFO] |  +- (io.reactivex.rxjava2:rxjava:jar:2.2.19:compile - version managed from 2.0.0; omitted for duplicate)
[INFO] |  \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] +- com.influxdb:influxdb-client-test:jar:4.1.0-SNAPSHOT:test
[INFO] |  +- com.squareup.okhttp3:mockwebserver:jar:4.7.2:test
[INFO] |  |  +- (com.squareup.okhttp3:okhttp:jar:4.7.2:test - version managed from 3.14.9; omitted for duplicate)
[INFO] |  |  \- junit:junit:jar:4.13:test
[INFO] |  |     \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] |  |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  |  +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] |  |  |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  |  \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] |  |  |     \- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] |  |     +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |     +- (org.opentest4j:opentest4j:jar:1.2.0:test - omitted for duplicate)
[INFO] |  |     \- (org.junit.platform:junit-platform-commons:jar:1.6.2:test - omitted for duplicate)
[INFO] |  +- org.junit.platform:junit-platform-runner:jar:1.6.2:test
[INFO] |  |  +- (junit:junit:jar:4.13:test - omitted for duplicate)
[INFO] |  |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |  +- org.junit.platform:junit-platform-launcher:jar:1.6.2:test
[INFO] |  |  |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |  |  \- (org.junit.platform:junit-platform-engine:jar:1.6.2:test - omitted for duplicate)
[INFO] |  |  \- org.junit.platform:junit-platform-suite-api:jar:1.6.2:test
[INFO] |  |     \- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  +- org.assertj:assertj-core:jar:3.16.1:test
[INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] |  +- org.mockito:mockito-core:jar:3.9.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.10.20:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.20:test
[INFO] |  |  \- org.objenesis:objenesis:jar:3.2:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:3.9.0:test
[INFO] |  |  +- (org.mockito:mockito-core:jar:3.9.0:test - omitted for duplicate)
[INFO] |  |  \- (org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test - omitted for conflict with 5.6.2)
[INFO] |  \- (com.google.code.findbugs:jsr305:jar:3.0.2:test - omitted for duplicate)
[INFO] \- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.008 s
[INFO] Finished at: 2022-01-14T08:18:40+01:00
[INFO] ------------------------------------------------------------------------

I will prepare PR to cover this.

Regards

@bednar
Copy link
Contributor

bednar commented Jan 14, 2022

@chb1828, #297 is prepared to review. Can you check correct behaviour?

@chb1828
Copy link
Author

chb1828 commented Jan 14, 2022

@bednar
I'm not familiar with open projects, so I tried to test it, but it failed.
Currently, I tried to run my project by getting the branch and adding it to gradle in the form of .jar.
It seems that the jar build doesn't work for some reason.
I'm really sorry, but can you point me in the direction I can review as I'm a beginner?
Thank you

@bednar
Copy link
Contributor

bednar commented Jan 17, 2022

@chb1828

The simplest way is:

  1. Clone repository - git clone https://github.com/influxdata/influxdb-client-java.git
  2. Build project by Maven - mvn clean install -DskipTests=true
  3. Use your SNAPSHOT version in your project - 4.1.0-SNAPSHOT

@chb1828
Copy link
Author

chb1828 commented Jan 17, 2022

@bednar
great!. It works fine.
My problem was that the jar didn't contain any other dependencies.
However, I did the workaround and confirmed that it works.

@bednar
Copy link
Contributor

bednar commented Jan 17, 2022

@chb1828 thanks for your confirmation 👍

@bednar bednar added bug Something isn't working and removed wontfix This will not be worked on labels Jan 17, 2022
@bednar bednar added this to the 4.1.0 milestone Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants