Open LikLiComing opened 2 months ago
The class loading stuff is kind of hacky no matter what because of the dependency on classes. I'm not sure that this is better (e.g. fewer situations where it doesn't work) vs anything else, but I'm open to a discussion or pointers for why this is better.
agree, this is uderlying code, we should be very careful for each single change, you can find more details in the QA below, please use it as reference and do enough testing, like 'try to find an overload of the method that accepts the class loader as a parameter.', look forwards to your team's effort.
Thanks for your attention, brendandburns.
"I'm facing an issue where the Kubernetes Java client (client-java) is loaded as expected when running in IntelliJ IDEA locally, but after packaging the application into a JAR via Maven or building a Docker image and then attempting to run it, the client-java JAR is not being loaded correctly. Despite this, I've confirmed that the client-java JAR is correctly included within both the Maven-built JAR and the Docker image.
Solution!!!!!!!!!!!!!!!!!!!!!!! Use "ClassLoader classLoader = Thread.currentThread().getContextClassLoader();" instead of "Yaml.class.getClassLoader()", and it works!!!! so please fix this issue, thanks![image](https://github.com/kubernetes-client/java/assets/35533817/79ac9248-515f-450c-ac9e-1b8c869cf875)
Describe the bug Unknown apiVersionKind XXXClass is it registered? and "No kubernetes api model classes found from classloader, this may break automatic api discovery"
Client Version since from
15.0.1
as I knowKubernetes Version N/A
Java Version Java 8
To Reproduce as it is deployed to server through CI and CD in way of JAR, we got wrong because of 'Yaml.class.getClassLoader()'
Expected behavior get all KubernetesObject class in package 'io.kubernetes.client.openapi.models', but fail, since It scan the running server JAR, not "java-client.jar"!
KubeConfig N/A
Server (please complete the following information):
Additional context N/A