Skip to content
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

Aspect works fine in native image with 3.0.5 but fails with 3.1.0 #30525

Closed
phejl opened this issue May 23, 2023 · 8 comments
Closed

Aspect works fine in native image with 3.0.5 but fails with 3.1.0 #30525

phejl opened this issue May 23, 2023 · 8 comments
Assignees
Labels
status: duplicate A duplicate of another issue status: feedback-provided Feedback has been provided theme: aot An issue related to Ahead-of-time processing

Comments

@phejl
Copy link

phejl commented May 23, 2023

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)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 23, 2023
@sdeleuze
Copy link
Contributor

I can have a look once you provide a repro.

@sdeleuze sdeleuze added the theme: aot An issue related to Ahead-of-time processing label May 23, 2023
@sdeleuze sdeleuze self-assigned this May 23, 2023
@phejl
Copy link
Author

phejl commented May 23, 2023

@sdeleuze I have some troubles preparing the repro (it is a nontrivial application). At the same time I have found this #30529

@phejl
Copy link
Author

phejl commented May 24, 2023

@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

@phejl
Copy link
Author

phejl commented May 24, 2023

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

@sdeleuze
Copy link
Contributor

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?

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label May 30, 2023
@phejl
Copy link
Author

phejl commented May 30, 2023

@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?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 30, 2023
@sbrannen
Copy link
Member

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 spring-projects/spring-boot#35564.

@phejl
Copy link
Author

phejl commented May 30, 2023

@sbrannen Nice! Thank you.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@sdeleuze sdeleuze added the status: duplicate A duplicate of another issue label May 30, 2023
@snicoll snicoll removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue status: feedback-provided Feedback has been provided theme: aot An issue related to Ahead-of-time processing
Projects
None yet
Development

No branches or pull requests

5 participants