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

java.lang.NoClassDefFoundError: okhttp3/Interceptor #832

Closed
tovbinm opened this issue Jun 6, 2022 · 17 comments · Fixed by #839
Closed

java.lang.NoClassDefFoundError: okhttp3/Interceptor #832

tovbinm opened this issue Jun 6, 2022 · 17 comments · Fixed by #839
Assignees
Labels
released triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tovbinm
Copy link

tovbinm commented Jun 6, 2022

java.lang.NoClassDefFoundError: okhttp3/Interceptor
    at com.google.maps.GeoApiContext$Builder.<init>(GeoApiContext.java:389)
Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor
    at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 9 more

Environment details

  1. Java 11
  2. Mac OS X 12.3.1
  3. com.google.maps:google-maps-services:2.1.0

Code example

new GeoApiContext.Builder().apiKey("...")

Additional information

The issue does not exist on com.google.maps:google-maps-services:2.0.0

@tovbinm tovbinm added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 6, 2022
@raghulvishnudhinesh
Copy link

Happens on java 8 also An error occurred while executing a save: java.lang.NoClassDefFoundError: okhttp3/Interceptor] (APNX-1-4198-000)

@benwaffle
Copy link

I see the okhttp 5.0.0-alpha7 jar has no class files in it. Is this a Java 9 modules thing? An issue with how okhttp published it?

❯ zipinfo okhttp-5.0.0-alpha.7.jar
Archive:  okhttp-5.0.0-alpha.7.jar
Zip file size: 13361 bytes, number of entries: 20
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 META-INF/
-rw-r--r--  2.0 unx       25 b- defN 22-Apr-27 03:58 META-INF/MANIFEST.MF
-rw-r--r--  2.0 unx      811 b- defN 22-Apr-27 03:58 META-INF/kotlin-project-structure-metadata.json
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/root_package/
-rw-r--r--  2.0 unx       12 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/root_package/0_.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/
-rw-r--r--  2.0 unx     2751 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/1_http.knm
-rw-r--r--  2.0 unx      910 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/0_http.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3/
-rw-r--r--  2.0 unx     8627 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3/0_okhttp3.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/
-rw-r--r--  2.0 unx      650 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/0_internal.knm
-rw-r--r--  2.0 unx     1589 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/2_internal.knm
-rw-r--r--  2.0 unx     6109 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/1_internal.knm
-rw-r--r--  2.0 unx       75 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/module
-rw-r--r--  2.0 unx       95 b- defN 22-Apr-27 03:58 commonMain/default/manifest
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/resources/
20 files, 21654 bytes uncompressed, 10097 bytes compressed:  53.4%

okhttp 4.9.3 has class files

@pmayeur
Copy link

pmayeur commented Jun 13, 2022

@arriolac is there any update or timeline for a fix?

@Selaron
Copy link

Selaron commented Jun 14, 2022

okhttp Version 5.0.0-alpha.4 is the first version without class files.

New: Change the build from Kotlin-JVM to Kotlin-multiplatform (which includes JVM). Both native and JavaScript platforms are unstable preview releases and subject to backwards-incompatible changes in forthcoming releases.

Stephan202 added a commit to PicnicSupermarket/google-maps-services-java that referenced this issue Jun 22, 2022
This change partially reverts the upgrade performed in googlemaps#829, and is an
alternative fix for googlemaps#816. OkHttp depends on Kotlin 1.6.20, which is not
vulnerable to CVE-2020-29582.

This downgrade also resolves googlemaps#832.

See:
- https://square.github.io/okhttp/changelogs/changelog_4x/#version-4100
- https://nvd.nist.gov/vuln/detail/CVE-2020-29582
@Stephan202
Copy link
Contributor

I filed #839, which should resolve this issue.

@benwaffle
Copy link

benwaffle commented Jun 22, 2022

If it is related to the kotlin-multiplatform change, that's here - square/okhttp@3ad1912.

@swankjesse, do you have any insight, could this NoClassDefFoundError be related to that commit

@swankjesse
Copy link

We’re tracking this here:
square/okhttp#7339

In 5.x we adopted a Gradle feature for resolving artifacts that doesn’t work in Maven, so we’re going to update our builds to not require that feature.

@benwaffle
Copy link

thanks! Does that issue apply even when just the library (google-maps-services-java) depends on okhttp3 and the app does not?

@raghulvishnudhinesh
Copy link

Any updates on the fix?

@Stephan202
Copy link
Contributor

It would be nice if one of the maintainers had a look at #839.

@irineuruiz
Copy link

Same problem here, due to this issue we can't update the jar from 2.0.0 to 2.1.0

googlemaps-bot pushed a commit that referenced this issue Oct 18, 2022
## [2.1.1](v2.1.0...v2.1.1) (2022-10-18)

### Bug Fixes

* Downgrade OkHttp 5.0.0-alpha.7 -> 4.10.0 ([71a2128](71a2128)), closes [#829](#829) [#816](#816) [#832](#832) [/square.github.io/okhttp/changelogs/changelog_4x/#version-4100](https://github.com//square.github.io/okhttp/changelogs/changelog_4x//issues/version-4100)
* fixes merge conflict artifacts ([1999ac7](1999ac7))
@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@irineuruiz
Copy link

@zhengcan
Copy link

@amuramoto
Copy link
Member

Oops - looks like something borked in the release action. Just published as 2.1.2

@pwayner
Copy link

pwayner commented Feb 15, 2023

I just cloned the repo, built a jar with gradlew that's labeled 2.1.2 but I'm getting this error when I move the JAR to another project:

Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/Interceptor
at com.google.maps.GeoApiContext$Builder.(GeoApiContext.java:389)
at org.wayner.json.util.GoogleMapServices.test1(GoogleMapServices.java:24)
at org.wayner.json.util.GoogleMapServices.main(GoogleMapServices.java:44)
Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor
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:520)
... 3 more

Any ideas?

@vijayselvas
Copy link

getting the same error with 2.2.0.

Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor not found by google-maps-2.1.0 [642]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1597)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 158 common frames omitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.