spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support

Home Page:https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnsupportedFeatureError: Proxy class defined by interfaces[xxxx] 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.

toohandsome opened this issue · comments

hello guys, could you help me?

I hava already add

@AotProxyHint(targetClass=AcController.class,proxyFeatures = ProxyBits.IS_STATIC)
@JdkProxyHint(types = {
        org.springframework.beans.factory.SmartInitializingSingleton.class,
        org.springframework.context.ApplicationContextAware.class,
        org.springframework.beans.factory.BeanNameAware.class,
        org.springframework.beans.factory.config.BeanPostProcessor.class,
        org.springframework.context.ApplicationListener.class,
        org.springframework.beans.factory.BeanFactoryAware.class,
        org.springframework.beans.factory.InitializingBean.class
})

in @SpringBootApplication DemoApplication,
but still get error.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationManagementConfigurer': Initialization of bean failed; nested exception is com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.beans.factory.SmartInitializingSingleton, interface org.springframework.context.ApplicationContextAware, interface org.springframework.beans.factory.BeanNameAware, interface org.springframework.beans.factory.config.BeanPostProcessor, interface org.springframework.context.ApplicationListener] 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=<comma-separated-config-files> and -H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[na:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]
        at com.yxd.xiaomi2meidi.DemoApplication.main(DemoApplication.java:51) ~[xiaomi2meidi.exe:0.0.1-SNAPSHOT]
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.beans.factory.SmartInitializingSingleton, interface org.springframework.context.ApplicationContextAware, interface org.springframework.beans.factory.BeanNameAware, interface org.springframework.beans.factory.config.BeanPostProcessor, interface org.springframework.context.ApplicationListener] 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=<comma-separated-config-files> and -H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.
        at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na]
        at com.oracle.svm.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:158) ~[na:na]
        at java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:48) ~[xiaomi2meidi.exe:na]
        at java.lang.reflect.Proxy.getProxyClass(Proxy.java:398) ~[xiaomi2meidi.exe: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) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:97) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:78) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:341) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[xiaomi2meidi.exe:5.3.22]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[xiaomi2meidi.exe:5.3.22]
        ... 15 common frames omitted

My environment is:
GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06)
Spring Boot: 2.7.3
spring-aot-maven-plugin: 0.12.1

After compiling ( mvn clean package -DskipTests -Pnative )
when I run my program, I get the above error.

Please find my minimal code sample here : https://github.com/toohandsome/springnative

Thanks

This happens due to the order of Proxy instances requested during or after the creation/initialization of a bean, as per the docs on Dynamic Proxy in the GraalVM website.

In practice, you should use a GraalVM-based JDK and let the tracing agent correctly detect which Proxy classes and other resources are required and then automatically generate the *-config.json files. Check out the GraalVM docs on the tracing agent.