java.lang.NoClassDefFoundError in 3.5.0
See original GitHub issueWhen I used the 3.5.0 version of okhttp, I encountered a weird exception
Exception in thread “main” java.lang.NoClassDefFoundError: okio/BufferedSource
at okhttp3.internal.Util.<clinit>(Util.java:48)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:121)
at com.demo.okHttp.Demo.main(Demo.java:8)
Caused by: java.lang.ClassNotFoundException: okio.BufferedSource
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 3 more
however, when I use the 3.2 it works fine. My code is as simple as
public static void main(String[] args) { OkHttpClient client = new OkHttpClient(); }
and I have okhttp 3.5.0 and okio 1.11.0 imported to my project. Is this a bug in the 3.5.0 version, how can I solve this problem?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
you need also download the okio.jar as your project module
@runyan @smileboywtu @kinsleykajiva @Danc2050 I’m creating a java library where I’m using okhttp client and it working fine when tested. The java library will be reused across java applications. But when importing the library as a dependency in other application, I’m getting the same error as above, during the application startup.
Attaching below is dependency added in my library pom.xml. Appreciate your help. <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.10.0</version> </dependency>