spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 356 forks source link

spring aop error #1611

Closed zhangyajie4396 closed 2 years ago

zhangyajie4396 commented 2 years ago

image

proxy-config.json: [ [ "org.springframework.beans.factory.config.BeanPostProcessor", "org.springframework.beans.factory.BeanFactoryAware", "org.springframework.beans.factory.BeanClassLoaderAware" ] ]

pom.xml: `

11 11 0.11.5 org.springframework.boot spring-boot-maven-plugin paketobuildpacks/builder:tiny true org.springframework.experimental spring-aot-maven-plugin ${spring-native.version} generate generate test-generate test-generate org.hibernate.orm.tooling hibernate-enhance-maven-plugin 5.6.7.Final true true true true false enhance native org.junit.platform junit-platform-launcher test org.graalvm.buildtools native-maven-plugin 0.9.11 true build-native build package test-native test test org.springframework.boot spring-boot-maven-plugin exec ` but error,what is the problem?: `org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor': Initialization of bean failed; nested exception is com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.beans.factory.config.BeanPostProcessor, interface org.springframework.beans.factory.BeanFactoryAware, interface org.springframework.beans.factory.BeanClassLoaderAware] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[na:na] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[na:na] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[na:na] at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[na:na] at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) ~[na:na] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[na:na] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[na:na] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[mgm-web:2.6.7] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[mgm-web:2.6.7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[mgm-web:2.6.7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[mgm-web:2.6.7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[mgm-web:2.6.7] at com.github.hqh.mgm.MgmApplication.main(MgmApplication.java:31) ~[mgm-web:0.0.1-SNAPSHOT] Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.beans.factory.config.BeanPostProcessor, interface org.springframework.beans.factory.BeanFactoryAware, interface org.springframework.beans.factory.BeanClassLoaderAware] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na] at com.oracle.svm.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:146) ~[na:na] at java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:66) ~[mgm-web:na] at java.lang.reflect.Proxy.getProxyClass(Proxy.java:384) ~[mgm-web:na] at org.springframework.util.ClassUtils.createCompositeInterface(ClassUtils.java:784) ~[na:na] at org.springframework.aop.aspectj.AspectJExpressionPointcut.getTargetShadowMatch(AspectJExpressionPointcut.java:437) ~[na:na] at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:295) ~[na:na] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:251) ~[na:na] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:289) ~[na:na] at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:321) ~[na:na] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:128) ~[mgm-web:5.3.19] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:97) ~[mgm-web:5.3.19] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:78) ~[mgm-web:5.3.19] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:341) ~[mgm-web:5.3.19] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293) ~[mgm-web:5.3.19] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[na:na] ... 15 common frames omitted`
Sochene commented 2 years ago

maybe this issue is same to #1580

Sochene commented 2 years ago

you can try to add

@TypeHint(types = {OrderedRequestContextFilter.class},access = {PUBLIC_METHODS, QUERY_PUBLIC_METHODS})
mhalbritter commented 2 years ago

Looks a lot like a duplicate of https://github.com/spring-projects-experimental/spring-native/issues/1580