question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError in 3.5.0

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
smileboywtucommented, Jul 25, 2017

you need also download the okio.jar as your project module

0reactions
aniruddhdandotiyacommented, Jun 15, 2022

@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>

    <dependency>
        <groupId>com.squareup.okio</groupId>
        <artifactId>okio-jvm</artifactId>
        <version>3.0.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.6.20</version>
        <scope>compile</scope>
    </dependency>
Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoClassDefFoundError in 3.5.0 (but works in 3.4.8)
error when running Mockito under a Robolectric environment. There's a simple test in the robolectric repo that passes with mockito-inline 3.4.8 ...
Read more >
Maven build failing because of "Exception in thread "main ...
Maven build failing because of "Exception in thread "main" java.lang.NoClassDefFoundError: javax/crypto/spec/Sec retKeySpec".
Read more >
Exception "java.lang.NoClassDefFoundError: oracle/security ...
This happens because Oracle Java SSL Libraries are not visible from the Oracle SOAP shared libraries classloader . The exception thrown is. java ......
Read more >
NoClassDefFoundError in runtime on API 19 and below when ...
After upgrading Android Gradle Plugin to 3.5.0-beta04 (from 3.4.1) we are getting java.lang.NoClassDefFoundError at runtime from the Android Job library ...
Read more >
Mule Version: 3.5.0 Build Id: 201307221644 is not able to start ...
While I am trying to create a new project in the Mule Studio 3.5, the following error has occurred. java.lang.NoClassDefFoundError: Could not initialize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found