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

Cannot instantiate MockWebServer on alpha 14​: java.lang.NoClassDefFoundError: okhttp3/internal/_UtilJvmKt #8374

Closed
edysli opened this issue Apr 18, 2024 · 3 comments
Labels
bug Bug in existing code

Comments

@edysli
Copy link

edysli commented Apr 18, 2024

Upgrading from 5.0.0-alpha.12 to 5.0.0-alpha.14 makes our tests fail with java.lang.NoClassDefFoundError: okhttp3/internal/_UtilJvmKt.

Example test to reproduce

import mockwebserver3.MockWebServer;
import org.junit.jupiter.api.Test;

class MockWebServerTest {
    @Test
    void create() {
        new MockWebServer();
    }
}

fails with:

java.lang.NoClassDefFoundError: okhttp3/internal/_UtilJvmKt
	at mockwebserver3.MockWebServer.<init>(MockWebServer.kt:105)
	at MockWebServerTest.create(MockWebServerTest.java:9)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: okhttp3.internal._UtilJvmKt
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 5 more

I've also noticed that the transitive dependencies differ between 5.0.0-alpha.12 and 5.0.0-alpha.14. Maybe the cause lies there...

+- com.squareup.okhttp3:mockwebserver3-junit5:jar:5.0.0-alpha.12:test
|  +- com.squareup.okhttp3:mockwebserver3:jar:5.0.0-alpha.12:test
|  |  \- com.squareup.okhttp3:okhttp-jvm:jar:5.0.0-alpha.12:test
|  |     \- com.squareup.okio:okio-jvm:jar:3.7.0:test
|  \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.23:test
|     \- org.jetbrains:annotations:jar:13.0:test
+- com.squareup.okhttp3:mockwebserver3-junit5:jar:5.0.0-alpha.14:test
|  +- com.squareup.okhttp3:mockwebserver3:jar:5.0.0-alpha.14:test
|  |  \- com.squareup.okhttp3:okhttp:jar:4.12.0:test
|  |     +- com.squareup.okio:okio:jar:3.6.0:test
|  |     |  \- com.squareup.okio:okio-jvm:jar:3.6.0:test
|  |     |     \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.23:test
|  |     \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.9.23:test
|  |        \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.9.23:test
|  \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.23:test
|     \- org.jetbrains:annotations:jar:13.0:test
@edysli edysli added the bug Bug in existing code label Apr 18, 2024
@yschimke
Copy link
Collaborator

OkHttp 4.12 looks broken. Are you saying alpha.14 is pulling that in?

@yschimke
Copy link
Collaborator

@edysli
Copy link
Author

edysli commented Apr 18, 2024

Indeed, you are correct: I have Spring Boot pinning OkHttp to 4.12.0 on my project. Sorry for the noise! 😟
Running mvn dependency:tree with -Dverbose=true would have revealed this.

@edysli edysli closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code
Projects
None yet
Development

No branches or pull requests

2 participants