fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.42k stars 1.46k forks source link

NoClassDefFoundError io/fabric8/kubernetes/client/dsl/ServerSideApplicable #6570

Open prakashreddy-97 opened 3 days ago

prakashreddy-97 commented 3 days ago

Describe the bug

Hello Team,

I am trying to use the @EnableKubernetesMockClient annotation to create a kubernetesClient in my test class which are in juupiter junit, but I am getting the following error.

NoClassDefFoundError io/fabric8/kubernetes/client/dsl/ServerSideApplicable

Fabric8 Kubernetes Client version

6.3.1

Steps to reproduce

import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; import org.junit.jupiter.api.Test;

@EnableKubernetesMockClient class MyTest {

KubernetesClient client;

Code

}

Expected behavior

Would like to get a mocked value for kubernetsClient

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.25.3@latest

Environment

Windows

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

manusa commented 2 days ago

You seem to be using an older version of the client (6.3.1). I also suspect that your project might also be using a third-party library or framework such as Spring, Quarkus, etc. that might also bring a newer (or older version of the client). Could you please confirm this?

prakashreddy-97 commented 10 hours ago

Hey @manusa, Yes we are using the springboot framework(3.0.19), java version 17. We were using groovy for unit tests before upgrading to these versions and couldn't mock the kubernetes-client. Thats when we started using the jupiter-junit and still could not mock the kubernetes-client.

manusa commented 10 hours ago

Are you using Spring Cloud Kubernetes too? Check if the Fabric8 Kubernetes Client is being imported transitively from one of those libraries. It's likely that you have a version convergence issue.

prakashreddy-97 commented 10 hours ago

We are not using Spring Cloud Kubernetes, and there are no other dependencies that import kubernetes-client

manusa commented 10 hours ago

Try to create a reproducer project then. The code you showed should be working with a standard Kubernetes Client project setup.

prakashreddy-97 commented 10 hours ago

Ok, will try that and get back to you. Thank you