kubernetes-client: java.lang.NoClassDefFoundError: io/fabric8/kubernetes/internal/KubernetesDeserializer
With 5.8.0 running on OSGI we get a NoClassDefFoundError.
The io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl
from the kubernetes-client
module is referencing the io.fabric8.kubernetes.internal.KubernetesDeserializer
class from the kubernetes-model-core
module which declares the package io.fabric8.kubernetes.internal
as private and doesn’t export it.
java.lang.NoClassDefFoundError: io/fabric8/kubernetes/internal/KubernetesDeserializer
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl.<init>(HasMetadataOperationsImpl.java:62)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl.<init>(HasMetadataOperationsImpl.java:39)
at io.fabric8.kubernetes.client.ResourceHandlerImpl.operation(ResourceHandlerImpl.java:70)
at io.fabric8.kubernetes.client.Handlers.getOperation(Handlers.java:65)
at io.fabric8.kubernetes.client.Handlers.getNonListingOperation(Handlers.java:69)
at io.fabric8.kubernetes.client.V1AuthorizationAPIGroupClient.selfSubjectAccessReview(V1AuthorizationAPIGroupClient.java:40)
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 27 (15 by maintainers)
Sorry - I am currently OOO and I don’t have access to any machine to test it. As far as I recall, we used the bundle jar back then when the issue has occured. I will try to verify this once again at the beginning of next week.
Hello guys, I have tried preparing a reproducer project https://github.com/rohankanojia-forks/kubernetes-client-osgi-demo . Basically, I’m just creating a Book custom resource. I’m sure control that goes through HasMetadataOperationsImpl and custom resource class is registered via KubernetesDeserializer
I deployed this application to Kubernetes using Kubernetes Maven Plugin where it’s run in a Karaf based image:
As expected I was able to see Book resources being created every second:
Could you please check if I have prepared the reproducer correctly 🙏 ? It could be possible that I have missed something since I’m not familiar with OSGi.
Same for me. Even when using the bundle version, the exception occurs at runtime.
From an OSGi point of view the issue seems to be clear: bundle A (client jar) uses a class (deserializer) from bundle B (model jar) which is not exported/imported properly. Because the import cannot be resolved at runtime, the exception is raised by the JVM.
To check why the existing integration test is passing successfully, it could be helpful to verify the class loader (I assume it is using a shared class loader whereas each bundle has its own in an OSGi environment).
I’ll get it tested on Monday, thanks for looking into it!
@hakontro @hanneshofmann : Would it be possible for you to also try out using
kubernetes-client-*-bundle.jar
instead ofkubernetes-client*.jar
to see if it resolves your issue?https://github.com/fabric8io/kubernetes-client/blob/7f76db5f80e8a824526a5e83e2938c259c904776/platforms/karaf/itests/pom.xml#L36-L47