You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
It is a spring boot 2.4 kotlin application that is supposed to be used from command line. It uses an application.yml file located in the classpath and mapped to data classes via the @ConfigurationProperty annotation. This works fine on the JVM but it doesn't with graal native. The application compiles fine but when it start, it fails with a classic error saying it can't bind yml file to object properties.
APPLICATION FAILED TO START
***************************
Description:
Binding to target [Bindable@25f04156 type = java.util.List<org.eumetsat.coda.maintenance.configuration.CodaInstance>, value = 'none', annotations = array<Annotation>[[empty]]] failed:
Property: coda.instances[0].description
Value: OFL Primary Backend
Origin: class path resource [application.yml] - 7:18
Reason: The elements [....] were left unbound```
it is a possibility, as that annotation relies on reflection to infer the constructor to bind to. Unfortunately I have no experience with graal and I don't know how to proceed.
After a quick check anyway I can tell you that I see support for @ConstructorBinding annotation in this project, but I don't see support for org.springframework.core.KotlinDetector which is used here. Maybe this is kotlin specific?
I'm running into a similar problem with a Java application and nested yaml properties. I can work around it to some extent, but it's not always the easiest to figure out how.
@aclement I can reproduce it with the following modified boot-features sample and have crafted a draft fix for it (it fixed the issue) by adding configuration for return types instead of nested types, see sdeleuze@non-nested-configuration-properties. Could you provide me some guidance and/or take it from there?
Notice that with the log I added I see that a lot (all?) properties are processed, whatever we use them or not. So I see reflection entries for properties like ArtemisProperties. I have the feeling that we don't filter out the @EnableConfigurationProperties on excluded auto-configurations. Should I create an issue for that, and if yes, for which version?
sorry but my project still not run, even with the latest 0.9.1 version and spring boot 2.4.4. New error anyway:
java.lang.ClassNotFoundException: java.util.List at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60) ~[na:na] at java.lang.ClassLoader.loadClass(ClassLoader.java:281) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.parseType(KDeclarationContainerImpl.kt:267) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.loadParameterTypes(KDeclarationContainerImpl.kt:258) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findConstructorBySignature(KDeclarationContainerImpl.kt:229) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:67) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:36) ~[na:na] at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62) ~[na:na] at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(KFunctionImpl.kt) ~[na:na] at kotlin.reflect.jvm.ReflectJvmMapping.getJavaConstructor(ReflectJvmMapping.kt:71) ~[na:na] at org.springframework.beans.BeanUtils$KotlinDelegate.findPrimaryConstructor(BeanUtils.java:827) ~[na:na]
Activity
sdeleuze commentedon Dec 15, 2020
I can reproduce it with 0.8.4 as well, maybe a
@ConstructorBindingsupport related issue?fer-marino commentedon Dec 15, 2020
it is a possibility, as that annotation relies on reflection to infer the constructor to bind to. Unfortunately I have no experience with graal and I don't know how to proceed.
After a quick check anyway I can tell you that I see support for
@ConstructorBindingannotation in this project, but I don't see support fororg.springframework.core.KotlinDetectorwhich is used here. Maybe this is kotlin specific?jimbethancourt commentedon Jan 14, 2021
I'm running into a similar problem with a Java application and nested yaml properties. I can work around it to some extent, but it's not always the easiest to figure out how.
sdeleuze commentedon Jan 28, 2021
@jimbethancourt Could you please provide some details on the workaround you are using?
jimbethancourt commentedon Jan 28, 2021
Hi @sdeleuze,
You bet - I'll put something together tonight.
Thanks,
Jim
jimbethancourt commentedon Jan 29, 2021
Hi @sdeleuze
I didn't have an opportunity to put something together tonight - I'll try to put something together very soon.
Short and sweet version is that I need to
Without Spring Native, the child object is created without issues. With Spring Native, I need to use a hierarchical approach.
Thanks,
Jim
sdeleuze commentedon Feb 3, 2021
This bug happens because only nested types are registered automatically, not the one returned by the getter.
sdeleuze commentedon Feb 3, 2021
@aclement I can reproduce it with the following modified
boot-featuressample and have crafted a draft fix for it (it fixed the issue) by adding configuration for return types instead of nested types, see sdeleuze@non-nested-configuration-properties. Could you provide me some guidance and/or take it from there?Notice that with the log I added I see that a lot (all?) properties are processed, whatever we use them or not. So I see reflection entries for properties like
ArtemisProperties. I have the feeling that we don't filter out the@EnableConfigurationPropertieson excluded auto-configurations. Should I create an issue for that, and if yes, for which version?jimbethancourt commentedon Feb 4, 2021
@sdeleuze and @aclement do you need the sample I mentioned? I apologise for not getting it to you yet.
sdeleuze commentedon Feb 9, 2021
@jimbethancourt No need for the repro thanks.
sdeleuze commentedon Feb 16, 2021
I will discuss with @bclozel tomorrow to try to define a reasonable and reliable implementation strategy.
[-]annotation processor and yaml files[/-][+]Fix @ConstructorBinding on non nested class[/+]fer-marino commentedon Mar 29, 2021
sorry but my project still not run, even with the latest 0.9.1 version and spring boot 2.4.4. New error anyway:
java.lang.ClassNotFoundException: java.util.List at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60) ~[na:na] at java.lang.ClassLoader.loadClass(ClassLoader.java:281) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.parseType(KDeclarationContainerImpl.kt:267) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.loadParameterTypes(KDeclarationContainerImpl.kt:258) ~[na:na] at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findConstructorBySignature(KDeclarationContainerImpl.kt:229) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:67) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:36) ~[na:na] at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62) ~[na:na] at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31) ~[na:na] at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(KFunctionImpl.kt) ~[na:na] at kotlin.reflect.jvm.ReflectJvmMapping.getJavaConstructor(ReflectJvmMapping.kt:71) ~[na:na] at org.springframework.beans.BeanUtils$KotlinDelegate.findPrimaryConstructor(BeanUtils.java:827) ~[na:na]sdeleuze commentedon Mar 29, 2021
@aclement Do you think we should reopen this issue?
aaronriekenberg commentedon Apr 15, 2021
I had the same issue as @fer-marino . For me putting:
into
refect-config.jsonsolved this issue.From what I can see this happens when a class using
@ConfigurationPropertiesand@ConstructorBindingcontains a List member, as here: https://github.com/fer-marino/spring-native-issue/blob/master/src/main/kotlin/org/eumetsat/coda/maintenance/configuration/CodaConfiguration.kt#L7Avoiding use of List in
@ConfigurationPropertiesand@ConstructorBindingclasses also avoids this issue for me.Thanks!
aclement commentedon Apr 15, 2021
I've tweaked the configuration properties processing a little and the case I could recreate as failing is now working.
Allow java.util types to have basic reflect access when used in prope…
AndreKoepke commentedon Dec 3, 2022
Same problem here with Spring 3.0.0, java-properties and gradle. I didn't found an option to set a "refect-config.json".
https://github.com/AndreKoepke/home-system/blob/9d35fc9c6e5fc6d7234ee871134902246c61e695/src/main/java/ch/akop/homesystem/config/properties/HomeSystemProperties.java#L35
Can I fix that without refactoring all configs classes?