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

Getting java.lang.NoSuchMethodError after upgraing to 21.0.0 #3539

Open
munishchouhan opened this issue Jul 5, 2024 · 3 comments
Open

Getting java.lang.NoSuchMethodError after upgraing to 21.0.0 #3539

munishchouhan opened this issue Jul 5, 2024 · 3 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@munishchouhan
Copy link

Describe the bug
getting java.lang.NoSuchMethodError: 'void io.kubernetes.client.openapi.models.V1Pod.validateJsonObject(com.google.gson.JsonObject)' at

k8sClient.coreV1Api()
                .createNamespacedPod(namespace, spec)
                .execute()

after upgrading to 21.0.0

Client Version
21.0.0

Kubernetes Version
v1.28.3+k3s2

Java Version
Java 11

To Reproduce
Steps to reproduce the behavior:

Expected behavior
should not throw error

KubeConfig
I am using colima

Server (please complete the following information):

  • Locally on MAC OS 14.5

Additional context

java.lang.NoSuchMethodError: 'void io.kubernetes.client.openapi.models.V1Pod.validateJsonObject(com.google.gson.JsonObject)'
	at io.kubernetes.client.openapi.models.V1Pod$CustomTypeAdapterFactory$1.read(V1Pod.java:309)
	at io.kubernetes.client.openapi.models.V1Pod$CustomTypeAdapterFactory$1.read(V1Pod.java:299)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:308)
	at com.google.gson.Gson.fromJson(Gson.java:1361)
	at com.google.gson.Gson.fromJson(Gson.java:1262)
	at com.google.gson.Gson.fromJson(Gson.java:1171)
	at com.google.gson.Gson.fromJson(Gson.java:1137)
	at io.kubernetes.client.openapi.JSON.deserialize(JSON.java:778)
	at io.kubernetes.client.openapi.ApiClient.deserialize(ApiClient.java:895)
	at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:1105)
	at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1029)
	at io.kubernetes.client.openapi.apis.CoreV1Api.createNamespacedPodWithHttpInfo(CoreV1Api.java:10876)
	at io.kubernetes.client.openapi.apis.CoreV1Api$APIcreateNamespacedPodRequest.execute(CoreV1Api.java:10972)

@brendandburns
Copy link
Contributor

21.0.0 changed the underlying code generator and is incompatible with older versions, I suspect that you somehow have older versions of some parts of the client in your classpath somewhere.

You can use 21.0.0-legacy to maintain the old code generator, but you probably need to clean up your dependencies rather than stick to the legacy releases which will eventually be deprecated.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 6, 2024
@anders-swanson
Copy link

I had this same error, and it was due to multiple versions of the Kubernetes Java Client on the classpath. Fixing up my project's dependencies to only include a newer version fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

5 participants