Repository navigation
java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(byte[], okhttp3.MediaType)' #324
Description
Activity
- addedfeature requestA feature has been asked for or suggested by the communityA feature has been asked for or suggested by the community
on Nov 25, 2020 Identical issue, have reverted to
1.24.0until further updates.Resolved dependency tree of
1.24.0looks like:+--- com.auth0:auth0:1.24.0 | +--- com.squareup.okhttp3:okhttp:3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14Resolved dependency tree of
1.25.0looks like:+--- com.auth0:auth0:1.25.0 | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14In my case it is
okhttp3version resolution which causes this (I think) as the error seems to relate to the method deprecated inokhttp3 version 4, iecom.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9But interestingly different versions of
okhttp3are required withincom.auth0:auth0:1.25.0itself:com.squareup.okhttp3:okhttp:4.9.0com.squareup.okhttp3:logging-interceptor:3.14.9that depends oncom.squareup.okhttp3:okhttp:3.14.9
Reacted by Cihat Imamoglu, Harry Winser and kongoking- addedbug reportThis issue reports a suspect bug or issue with the SDK itselfThis issue reports a suspect bug or issue with the SDK itselfand removedfeature requestA feature has been asked for or suggested by the communityA feature has been asked for or suggested by the community
on Nov 30, 2020 Thanks for the detailed info and dependency tree reports. I'm back from holiday this week; will take a look and hopefully get a fix out soon.
Reacted by Ivar (aɪvɑr)I have #325 which is needed (just a bad miss on my part 😞), but I'm actually not able to reproduce this exact issue. If anyone has a small test app that reproduces this issue and could share it in a gist or a simple github repo, that would be great and I can then verify that the fix will indeed address the specific error raised here. Thanks all, apologies for this mistake!
Was able to reproduce in https://github.com/ivarprudnikov/test-auth0-java-dependency with a
build.gradlefile:plugins { id 'java' id 'application' id "org.springframework.boot" version "2.3.6.RELEASE" id "io.spring.dependency-management" version "1.0.10.RELEASE" } repositories { mavenCentral() jcenter() maven { url = uri("https://jitpack.io") } } sourceCompatibility = "11" dependencies { implementation "com.auth0:auth0:1.25.0" } mainClassName = 'hello.HelloWorld' jar { baseName = 'test-auth0-gradle' version = '0.1.0' }There are Github actions enabled and it tries to run the app which generates the failure we talk about here.
Reacted by Cihat Imamoglu and Jim AndersonFantastic, thank you @ivarprudnikov! I'm able to reproduce the issue with your example. I suspect it's the spring dependency management plugin using its bom for okhttp v3, overriding auth0-java's dependency on v4, but need to investigate more.
If I remove the Spring dependency management plugin (
io.spring.dependency-management), the provided example works as expected. The Spring dependency management specifies OkHttp version 3, which overrides the dependency on v4 in this library.As noted above, the specific issue is the change that replaced the (now deprecated as of version 4) call to
RequestBody.createwith its new form, and when using OkHttp v3, that method obviously doesn't exist.I've not worked extensively with the Spring dependency management plugin, but I have had to find some workarounds in the past to override dependency versions using an extension property, e.g. something like:
ext { set 'okhttp3.version', '4.9.0' }Perhaps someone with more knowledge of that dependency plugin may be aware of another workaround.
It could be fixed by adding strictly version into the dependencies
implementation("com.squareup.okhttp3:okhttp") { version { strictly '4.9.0' } }Or adding the BOM into the dependencyManagement
dependencyManagement { imports { mavenBom "com.squareup.okhttp3:okhttp-bom:4.9.0" } }Reacted by Jim Anderson, Cihat Imamoglu, sid, Artur, kvalda, Wences Llobet and VictoriaHaving the same issue... please fix asap!
Reacted by sid, Angga Maulana, Artur, Paulo Mateus and Christopher SvanefalkHey guys, any updates on this? Reverting down to 1.24 and trying to do a user update throws a:
com.auth0.exception.APIException: Request failed with status code 400: Payload validation error: 'Additional properties not allowed: nonce_supported,logins_count,last_login,last_ip,identities,updated_at,created_at,user_id (consider storing them in app_metadata or user_metadata. See "Users Metadata" in https://auth0.com/docs/api/v2/changes for more details)'.@zhGio it does not get fix managing the dependencies as described earlier?
The problem is a transitive dependency from Spring.
#324 (comment)Another solution could be to manage manually transitive dependencies from Spring:
https://docs.gradle.org/current/userguide/resolution_rules.html#sec:disabling_resolution_transitive_dependenciesWell unfortunately I'm using maven and not gradle and not sure how to apply the changes above mentioned
14 remaining items
I have tried it and now it really does show version 4.9.0 in dependency tree.
[INFO] +- com.auth0:auth0:jar:1.27.0:compile [INFO] | +- com.squareup.okhttp3:okhttp:jar:4.9.0:runtime [INFO] | | +- com.squareup.okio:okio:jar:1.17.2:runtime [INFO] | | \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.20:runtime [INFO] | | +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.20:runtime [INFO] | | \- org.jetbrains:annotations:jar:13.0:runtime [INFO] | +- com.squareup.okhttp3:logging-interceptor:jar:4.9.0:runtime [INFO] | | \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.4.20:runtime [INFO] | | \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.4.20:runtimeBut now when calling
new AuthAPI(auth0Issuer, auth0ClientId, auth0ClientSecret);it gives me the following error:
java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.<clinit>(Util.kt:71) at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239) at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1633) at okhttp3.HttpUrl$Companion.parse(HttpUrl.kt:1642) at okhttp3.HttpUrl.parse(HttpUrl.kt) at com.auth0.client.auth.AuthAPI.createBaseUrl(AuthAPI.java:177) at com.auth0.client.auth.AuthAPI.<init>(AuthAPI.java:74) at com.auth0.client.auth.AuthAPI.<init>(AuthAPI.java:96)Has anything changed about this call from version 1.24.0?
EDIT:
Effective pom was still showing me old okhhtp version, after restarting VSCode it now shows correct version. But now when calling new AuthAPI(auth0Issuer, auth0ClientId, auth0ClientSecret) for the first time it gives me the error from above, and on any further call it gives me this:java.lang.NoClassDefFoundError: Could not initialize class okhttp3.internal.Util at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239) at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1633) at okhttp3.HttpUrl$Companion.parse(HttpUrl.kt:1642) at okhttp3.HttpUrl.parse(HttpUrl.kt) at com.auth0.client.auth.AuthAPI.createBaseUrl(AuthAPI.java:177) at com.auth0.client.auth.AuthAPI.<init>(AuthAPI.java:74) at com.auth0.client.auth.AuthAPI.<init>(AuthAPI.java:96)Reopening based on above, thanks for providing the sample to reproduce, we'll follow up here with additional info once we reproduce and see what the solution may be.
Reacted by Mario Jugurčić@majugurci I think that error is similar, but related to
grpc-okhttpas you mentioned. Curious, what happens if you add this to yourdependencyManagement?<dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> <version>2.10.0</version> </dependency>
It seems to fix the problem!
I will test it more thoroughly in the next days but for now this basic call has passed.Now my pom.xml looks like this:
<dependencyManagement> <dependencies> <dependency> <groupId>${quarkus.platform.group-id}</groupId> <artifactId>${quarkus.platform.artifact-id}</artifactId> <version>${quarkus.platform.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp-bom</artifactId> <version>4.9.1</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>logging-interceptor</artifactId> </dependency> <dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> <version>2.10.0</version> </dependency> </dependencies> </dependencyManagement>Not pretty but at least it works.
Reacted by Jim Anderson, Konstantin Klimov and rsoudaniThe majority of these issues should be resolved in
1.28.1, which includes #342 to use methods available in OkHttp v3. It will be available in Maven Central later today. There may still be scenarios where configuring the dependencies to use OkHttp v4 is still required, and we cannot guarantee that future changes will be compatible forever, but it's a reasonable change that should address the majority of issues reported here. Closing this issue, but we'll continue to monitor for any other issues.Just an update, I have updated Auth0 to the latest version (currently 1.30.0) and these changes are not necessary in the pom.xml anymore.
Reacted by Jim Anderson and Filippo Fantinato- added 2 commits that reference this issue
on Apr 7, 2023 - added a commit that references this issue
on Apr 11, 2023 - added a commit that references this issue
on Apr 11, 2023 - added a commit that references this issue
on Apr 18, 2023 Identical issue, have reverted to
1.24.0until further updates.Resolved dependency tree of
1.24.0looks like:+--- com.auth0:auth0:1.24.0 | +--- com.squareup.okhttp3:okhttp:3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14Resolved dependency tree of
1.25.0looks like:+--- com.auth0:auth0:1.25.0 | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14In my case it is
okhttp3version resolution which causes this (I think) as the error seems to relate to the method deprecated inokhttp3 version 4, iecom.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9But interestingly different versions of
okhttp3are required withincom.auth0:auth0:1.25.0itself:com.squareup.okhttp3:okhttp:4.9.0com.squareup.okhttp3:logging-interceptor:3.14.9that depends oncom.squareup.okhttp3:okhttp:3.14.9
我也遇到了相同的问题,在springboot:2.6.14中引入了okhttp4.9.2,编译时未见有问题,运行时调用则报错,修改为官方推荐的3.14.9后问题解决,solved
Identical issue, have reverted to
1.24.0until further updates.
Resolved dependency tree of1.24.0looks like:+--- com.auth0:auth0:1.24.0 | +--- com.squareup.okhttp3:okhttp:3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14Resolved dependency tree of
1.25.0looks like:+--- com.auth0:auth0:1.25.0 | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9 | | \--- com.squareup.okio:okio:1.17.2 | +--- com.squareup.okhttp3:logging-interceptor:3.14.9 | | \--- com.squareup.okhttp3:okhttp:3.14.9 (*) | +--- com.fasterxml.jackson.core:jackson-databind:2.11.3 (*) | +--- commons-codec:commons-codec:1.15 -> 1.14 | \--- com.auth0:java-jwt:3.11.0 | +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 -> 2.11.3 (*) | \--- commons-codec:commons-codec:1.14In my case it is
okhttp3version resolution which causes this (I think) as the error seems to relate to the method deprecated inokhttp3 version 4, iecom.squareup.okhttp3:okhttp:4.9.0 -> 3.14.9
But interestingly different versions ofokhttp3are required withincom.auth0:auth0:1.25.0itself:com.squareup.okhttp3:okhttp:4.9.0com.squareup.okhttp3:logging-interceptor:3.14.9that depends oncom.squareup.okhttp3:okhttp:3.14.9
我也遇到了相同的问题,在springboot:2.6.14中引入了okhttp4.9.2,编译时未见有问题,运行时调用则报错,修改为官方推荐的3.14.9后问题解决,solved
this is right help me so much thank you
Hello,
after upgrading to the version 1.25.0 (from 1.24.0) i get the error in the title when getting TokenHolder.
My code looks the same as in your docs:
The problem is this line: TokenHolder holder = authRequest.execute();
In previous versions everything worked great but since update to 1.25.0 it throws the following error: