-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
@Validated in @ConfigurationProperties doesn't work when running in native image #6976
Comments
I tried running this app with
Why would these reflective accesses be registered by GraalVM? Have you tried running with the agent to collect reflection metadata? |
@RegisterReflectionForBinding(
Pattern::class,
Pattern.Flag::class) @vjovanov If I add the annotation, the application works but |
Can you please run the application with the native image agent so we can see all the produced JSON? |
@vjovanov I ran it with nativeCompile and nativeRun in gradle environment. Does the produced json say this? |
Isn't the produced json the link above? ./gradlew -Pagent run If I run java.lang.IllegalArgumentException: Could not find class [com.demo.search.middle.demo.DemooApplicationKt__ApplicationContextInitializer] The above error occurs. |
Not sure it is the same file. Does the |
@vjovanov
am trying to solve it. @sdeleuze |
Because of the above settings, it was run as an agent . As a result
How to solve above error when there is agent parameter? |
@KimSeongIl You can use Spring Boot
@vjovanov Let see what the agent says, if the usage of |
Thank you for answer. 😁 https://github.com/KimSeongIl/demo However, upgrading the spring boot version to 3.1.2 does not change anything. https://github.com/spring-projects/spring-boot/releases/tag/v3.1.2 Where in the release notes are the bugfixes related? |
@KimSeongIl I meant to fix the |
@sdeleuze
After running these commands, it works as expected. Why do I have to go through that process? Is it normal to have to go through that process? I couldn't find it in spring documentation. |
@KimSeongIl When the bug will be fixed either on GraalVM or Spring side, this "dance" won't be needed anymore, but for now yes that's what I would expect when you need to use the agent. Looks reasonable to me this is documented on GraalVM side as there is no Spring specific here (we may add a note later). @vjovanov Could you please check the agent output and let me know if you see something that GraalVM could fix or if you think I should take care of that on Spring side (I will have a deeper look after your feedback)? |
Can you please answer this issue? |
The relevant metadata is:
I do not see how GraalVM can prove this automatically. The proper fix would be for the framework that uses these flags to add the metadata into the jar. Until that happens, the workaround is to keep the config in your project. |
Ok let's go back on Spring side for this one -> spring-projects/spring-boot#37101. |
Describe the issue
It worked fine on the jvm, but when I run it on the native image I get an error.
But if I remove the Pattern annotation, it works fine.
Why is this issue occurring?
How can I solve this problem?
Steps to reproduce the issue
DemoContext.kt
application.yml
nativeRun result
Describe GraalVM and your environment
spring boot version: 3.1.0
graalvm plugin version: id("org.graalvm.buildtools.native") version "0.9.20"
graalvm version: 22.3.r17
More details
spring-projects/spring-boot#37101
discussed in the above issue
@sdeleuze said it looks like a graalvm bug.
The text was updated successfully, but these errors were encountered: