It seems aspect over repository does not work. I'll try to provide a repro.
It looks like registering the aspect for reflection fixes the issue.
com.oracle.svm.core.jdk.UnsupportedFeatureError: Runtime reflection is not supported for public java.lang.Object xxxx.EnsureIndexesAspect.ensureIndexes(org.aspectj.lang.ProceedingJoinPoint) throws java.lang.Throwable
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
at java.base@17.0.7/java.lang.reflect.Method.acquireMethodAccessor(Method.java:76)
at java.base@17.0.7/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:637)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:71)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
at jdk.proxy4/jdk.proxy4.$Proxy52.findAllByStatusAndStream(Unknown Source)
at xxx.ResetUploadsRunner.run(ResetUploadsRunner.java:33)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:751)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
at xxx.Application.main(Application.java:25)
Comment From: sdeleuze
I can have a look once you provide a repro.
Comment From: phejl
@sdeleuze I have some troubles preparing the repro (it is a nontrivial application). At the same time I have found this https://github.com/spring-projects/spring-framework/issues/30529
Comment From: phejl
@sdeleuze Ok, finally: https://github.com/phejl/spring-boot-30525 It seems the problem is triggered by:
@Query("{ 'uid': ?0 }")
Stream<Data> findAllByUidAndStream(String uid);
in DataRepository
Comment From: phejl
I can see similar issue while running nativeTest
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Runtime reflection is not supported for public void org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.setAddFilters(boolean)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
at java.base@17.0.7/java.lang.reflect.Method.acquireMethodAccessor(Method.java:76)
at java.base@17.0.7/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.setValue(JavaBeanBinder.java:397)
at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:104)
at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:86)
at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:62)
at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:476)
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590)
at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:576)
at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:474)
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:414)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:332)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:262)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:249)
at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:93)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:96)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:79)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:419)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
... 108 more
Comment From: sdeleuze
I can reproduce the issue, but does not look like a regression since I see it with both Spring Boot 3.0.7
and 3.1.0
.
Also when I add hints like below, the apps runs fine on native:
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(EnsureIndexesAspect.class, MemberCategory.INVOKE_DECLARED_METHODS);
}
So I am wondering if that's not just a duplicate of #28711.
@phejl Any thoughts?
Comment From: phejl
@sdeleuze Thanks for checking. Yes I think this happened somewhere between 3.0.5 and 3.0.7. I'm not 100% whether aspect worked but kind of regression is that app won't start anymore.
So I'll leave it to your judgment.
Is Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Runtime reflection is not supported for public void org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.setAddFilters(boolean)
error of the same cause or should a separate bug filed for it?
Comment From: sbrannen
Is
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Runtime reflection is not supported for public void org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.setAddFilters(boolean)
error of the same cause or should a separate bug filed for it?
That has already been addressed in https://github.com/spring-projects/spring-boot/issues/35564.
Comment From: phejl
@sbrannen Nice! Thank you.