-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
NullPointerException when compiled to Spring Native binary #3271
Comments
Done some digging and (sort of) found the issue, registering the Spring hints relies on the API model classes being annnotated with Updating this to find all classes in the Reflections reflections = new Reflections("io.kubernetes.client.openapi.models", Scanners.SubTypes.filterResultsBy(s -> true));
Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
LOGGER.info("Found {} apiModels", classes.size());
for (Class<?> clazz : classes) {
LOGGER.info("registering {} for reflection", clazz);
hints.reflection().registerType(clazz, allMemberCategories);
} 2024-04-03T13:58:31.395+01:00 INFO 17552 --- [ main] org.reflections.Reflections : Reflections took 272 ms to scan 2 urls, producing 565 keys and 5623 values
2024-04-03T13:58:31.489+01:00 INFO 17552 --- [ main] tesBeanFactoryInitializationAotProcessor : Found 1115 models
2024-04-03T13:58:31.489+01:00 INFO 17552 --- [ main] tesBeanFactoryInitializationAotProcessor : registering class io.kubernetes.client.openapi.models.V1beta1Variable$CustomTypeAdapterFactory for reflection
2024-04-03T13:58:31.489+01:00 INFO 17552 --- [ main] tesBeanFactoryInitializationAotProcessor : registering class io.kubernetes.client.openapi.models.V1Endpoint for reflection
... This appears to fix the use of the |
This is also mentioned in issue #3134 |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Thi should be soon solved thanks to kubernetes-client/gen#270 /remove-lifecycle stale |
Describe the bug
I am using Spring Shell to create a cli tool, the library works fine when run from the jar, however when compiled to a native binary and ran it throws a NullPointerException.
I have added the
client-java-spring-aot-integrations
dependency but it doesn't seem to have resolved anything, and I am also required to add the following toreflect-config.json
otherwise I get a different error.When running as native it errors after
Kubectl.get(...)
is invoked:Client Version
20.0.1
Kubernetes Version
1.29.1
Java Version
21.0.2-tem
GraalVM Version
21.0.2-graalce
To Reproduce
Reproducable example can be found here: https://github.com/rj93/k8s-cli-native-example
Expected behavior
A NullPointerExpcetion not to be thrown
KubeConfig
Server:
The text was updated successfully, but these errors were encountered: