Skip to content

“NoSuchMethodErrors” due to multiple versions of com.squareup.okhttp3:okhttp:jar #925

@Bing-ok

Description

@Bing-ok

Hi, there are multiple versions of com.squareup.okhttp3:okhttp in github-api-master. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only com.squareup.okhttp3:okhttp:4.4.1 can be loaded, and com.squareup.okhttp3:okhttp:3.12.3 will be shadowed.

As com.squareup.okhttp3:okhttp:3.12.3 has not been loaded during the building process, several methods are missing. However, the missing methods:
1. okhttp3.internal.Version: java.lang.String userAgent()

Check for details of invocation
paths------
<org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection: java.io.OutputStream getOutputStream()> github-api-master\target\classes
<okhttp3.internal.huc.OkHttpURLConnection: java.io.OutputStream getOutputStream()> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.huc.OkHttpURLConnection: okhttp3.Call buildCall()> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.huc.OkHttpURLConnection: java.lang.String defaultUserAgent()> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.Version: java.lang.String userAgent()>

2. okhttp3.internal.http.HttpDate: java.lang.String format(java.util.Date)

Check for details of invocation
paths------
<org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection: void setIfModifiedSince(long)> github-api-master\target\classes
<okhttp3.internal.huc.OkHttpURLConnection: void setIfModifiedSince(long)> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.http.HttpDate: java.lang.String format(java.util.Date)>

3. okhttp3.internal.platform.Platform: void log(int,java.lang.String,java.lang.Throwable)

Check for details of invocation
paths------
<org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection: void setRequestProperty(java.lang.String,java.lang.String)> github-api-master\target\classes
<okhttp3.internal.huc.OkHttpURLConnection: void setRequestProperty(java.lang.String,java.lang.String)> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.platform.Platform: void log(int,java.lang.String,java.lang.Throwable)>

4. okhttp3.internal.http.StatusLine: okhttp3.internal.http.StatusLine get(okhttp3.Response)

Check for details of invocation
paths------
<org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory$DelegatingHttpsURLConnection: java.lang.String getHeaderField(java.lang.String)> github-api-master\target\classes
<okhttp3.internal.huc.OkHttpURLConnection: java.lang.String getHeaderField(java.lang.String)> Repositories\com\squareup\okhttp3\okhttp-urlconnection\3.12.3\okhttp-urlconnection-3.12.3.jar
<okhttp3.internal.http.StatusLine: okhttp3.internal.http.StatusLine get(okhttp3.Response)>

The above missing methods are actually referenced by github-api-master, which will cause “NoSuchMethodErrors” at runtime.

Suggested fixing solutions:

  1. Upgrade dependency com.squareup.okhttp3:okhttp-urlconnection from 3.12.3 to 4.4.1. Because one conflicting library version com.squareup.okhttp3:okhttp:3.12.3 is transitively introduced by com.squareup.okhttp3:okhttp-urlconnection:3.12.3. Upgrading dependency com.squareup.okhttp3:okhttp-urlconnection from 3.12.3 to 4.4.1 can solve this dependency conflict.
  2. Change dependency com.squareup.okhttp3:okhttp from 4.4.1 to 3.12.3.

Please let me know which solution do you prefer? I can submit a PR to fix it.

Thank you very much for your attention.
Best regards,

Dependency tree----

click for details
[INFO] org.kohsuke:github-api:jar:1.117-SNAPSHOT
[INFO] +- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] +- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] | \- (org.hamcrest:hamcrest:jar:2.2:test - omitted for duplicate)
[INFO] +- org.hamcrest:hamcrest-library:jar:2.2:test
[INFO] | \- (org.hamcrest:hamcrest-core:jar:2.2:test - omitted for duplicate)
[INFO] +- junit:junit:jar:4.13:test
[INFO] | \- (org.hamcrest:hamcrest-core:jar:1.3:test - omitted for conflict with 2.2)
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.10.2:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.infradna.tool:bridge-method-annotation:jar:1.18:compile
[INFO] | \- org.jenkins-ci:annotation-indexer:jar:1.4:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.4:test
[INFO] | \- (commons-io:commons-io:jar:2.2:test - omitted for conflict with 2.4)
[INFO] +- commons-discovery:commons-discovery:jar:0.5:test
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:test
[INFO] +- org.kohsuke.stapler:stapler:jar:1.260:test
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:test
[INFO] | +- (commons-discovery:commons-discovery:jar:0.4:test - omitted for conflict with 0.5)
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.2:test
[INFO] | | +- (commons-logging:commons-logging:jar:1.1.1:test - omitted for duplicate)
[INFO] | | \- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | +- (commons-io:commons-io:jar:2.4:test - omitted for duplicate)
[INFO] | +- (commons-logging:commons-logging:jar:1.2:test - omitted for conflict with 1.1.1)
[INFO] | +- commons-codec:commons-codec:jar:1.9:test
[INFO] | +- org.jvnet.localizer:localizer:jar:1.7:test
[INFO] | +- org.kohsuke.stapler:json-lib:jar:2.4-jenkins-2:test
[INFO] | | +- (commons-beanutils:commons-beanutils:jar:1.8.0:test - omitted for conflict with 1.9.2)
[INFO] | | +- (commons-collections:commons-collections:jar:3.2.1:test - omitted for duplicate)
[INFO] | | +- commons-lang:commons-lang:jar:2.5:test
[INFO] | | +- (commons-logging:commons-logging:jar:1.1.1:test - omitted for duplicate)
[INFO] | | \- net.sf.ezmorph:ezmorph:jar:1.0.6:test
[INFO] | | \- (commons-lang:commons-lang:jar:2.3:test - omitted for conflict with 2.5)
[INFO] | +- org.jvnet:tiger-types:jar:2.2:test
[INFO] | +- com.google.guava:guava:jar:11.0.1:test
[INFO] | | \- (com.google.code.findbugs:jsr305:jar:1.3.9:test - omitted for conflict with 2.0.1)
[INFO] | +- org.kohsuke:asm5:jar:5.0.1:test
[INFO] | +- (commons-fileupload:commons-fileupload:jar:1.3.1-jenkins-2:test - omitted for conflict with 1.4)
[INFO] | +- com.google.code.findbugs:jsr305:jar:2.0.1:test
[INFO] | +- com.jcraft:jzlib:jar:1.1.3:test
[INFO] | \- (com.github.spotbugs:spotbugs-annotations:jar:3.1.12:test - omitted for conflict with 4.1.1)
[INFO] +- org.kohsuke.stapler:stapler-jetty:jar:1.1:test
[INFO] | +- (org.kohsuke.stapler:stapler:jar:1.177:test - omitted for conflict with 1.260)
[INFO] | \- org.eclipse.jetty:jetty-servlet:jar:7.5.4.v20111024:test
[INFO] | \- org.eclipse.jetty:jetty-security:jar:7.5.4.v20111024:test
[INFO] | \- org.eclipse.jetty:jetty-server:jar:7.5.4.v20111024:test
[INFO] | +- javax.servlet:servlet-api:jar:2.5:test
[INFO] | +- org.eclipse.jetty:jetty-continuation:jar:7.5.4.v20111024:test
[INFO] | \- org.eclipse.jetty:jetty-http:jar:7.5.4.v20111024:test
[INFO] | \- org.eclipse.jetty:jetty-io:jar:7.5.4.v20111024:test
[INFO] | \- org.eclipse.jetty:jetty-util:jar:7.5.4.v20111024:test
[INFO] +- org.eclipse.jgit:org.eclipse.jgit:jar:5.7.0.202003110725-r:test
[INFO] | +- com.jcraft:jsch:jar:0.1.55:test
[INFO] | +- (com.jcraft:jzlib:jar:1.1.1:test - omitted for conflict with 1.1.3)
[INFO] | +- com.googlecode.javaewah:JavaEWAH:jar:1.1.7:test
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.2:test
[INFO] | +- org.bouncycastle:bcpg-jdk15on:jar:1.64:test
[INFO] | | \- (org.bouncycastle:bcprov-jdk15on:jar:1.64:test - omitted for duplicate)
[INFO] | +- org.bouncycastle:bcprov-jdk15on:jar:1.64:test
[INFO] | \- org.bouncycastle:bcpkix-jdk15on:jar:1.64:test
[INFO] | \- (org.bouncycastle:bcprov-jdk15on:jar:1.64:test - omitted for duplicate)
[INFO] +- com.squareup.okio:okio:jar:2.5.0:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.3.70:compile
[INFO] | | +- (org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.70:compile - omitted for duplicate)
[INFO] | | \- org.jetbrains:annotations:jar:13.0:compile
[INFO] | \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.70:compile
[INFO] +- com.squareup.okhttp3:okhttp:jar:4.4.1:compile
[INFO] | +- (com.squareup.okio:okio:jar:2.4.3:compile - omitted for conflict with 2.5.0)
[INFO] | \- (org.jetbrains.kotlin:kotlin-stdlib:jar:1.3.61:compile - omitted for conflict with 1.3.70)
[INFO] +- com.squareup.okhttp3:okhttp-urlconnection:jar:3.12.3:compile
[INFO] | \- (com.squareup.okhttp3:okhttp:jar:3.12.3:compile - omitted for conflict with 4.4.1)
[INFO] +- com.squareup.okhttp:okhttp-urlconnection:jar:2.7.5:compile
[INFO] | \- com.squareup.okhttp:okhttp:jar:2.7.5:compile
[INFO] | \- (com.squareup.okio:okio:jar:1.6.0:compile - omitted for conflict with 2.5.0)
[INFO] +- org.kohsuke:wordnet-random-name:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:3.4.6:test
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.10.13:test
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.10.13:test
[INFO] | \- org.objenesis:objenesis:jar:2.6:test
[INFO] +- com.github.spotbugs:spotbugs-annotations:jar:4.1.1:provided
[INFO] | \- (com.google.code.findbugs:jsr305:jar:3.0.2:provided - omitted for conflict with 2.0.1)
[INFO] +- com.github.tomakehurst:wiremock-jre8-standalone:jar:2.27.1:test
[INFO] \- com.google.code.gson:gson:jar:2.8.6:test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions