spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

Add support for native-image

Open mhalbritter opened this issue 3 years ago • 2 comments

Hello!

I tried using spring-data-rest in a native image. The native image doesn't start, it fails with this exception: https://ge.spring.io/s/a66xyypotax3k/tests/:data-rest-mongodb:nativeAotTest/com.example.data.rest.mongodb.DataRestMongoDbApplicationAotTests/initializationError?top-execution=1

Main cause is:

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface java.util.List, interface org.springframework.aop.SpringProxy, interface org.springframework.aop.framework.Advised, interface org.springframework.core.DecoratingProxy] 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) ~[data-rest-mongodb:na]	
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1037) ~[data-rest-mongodb:na]	
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:126) ~[na:na]	
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:118) ~[na:na]	
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:97) ~[na:na]	
	at org.springframework.plugin.core.support.AbstractTypeAwareSupport.getBeans(AbstractTypeAwareSupport.java:94) ~[data-rest-mongodb:3.0.0-M1]	
	at org.springframework.plugin.core.support.PluginRegistryFactoryBean.getObject(PluginRegistryFactoryBean.java:38) ~[data-rest-mongodb:3.0.0-M1]	
	at org.springframework.hateoas.config.HateoasConfiguration.relProviderPluginRegistry(HateoasConfiguration.java:118) ~[data-rest-mongodb:2.0.0-SNAPSHOT]	
	at org.springframework.hateoas.config.HateoasConfiguration__BeanDefinitions.lambda$getRelProviderPluginRegistryInstanceSupplier$5(HateoasConfiguration__BeanDefinitions.java:138) ~[na:na]	
	at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[data-rest-mongodb:6.0.0-SNAPSHOT]	
	at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[data-rest-mongodb:6.0.0-SNAPSHOT]	
	at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:210) ~[na:na]	
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1224) ~[data-rest-mongodb:6.0.0-SNAPSHOT]	
	... 101 common frames omitted

See this smoke test for more details.

mhalbritter avatar Jul 28 '22 08:07 mhalbritter

blocked by: oracle/graal#4941

christophstrobl avatar Sep 15 '22 12:09 christophstrobl

@christophstrobl The upstream issue is closed now and it should be fixed in the https://github.com/oracle/graal/milestone/16 release.

buckett avatar Feb 21 '23 14:02 buckett