Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

我在尝试使用SpringBoot3.0构建NativeImages,但是无法正确获取到反射的类 #216

Open
cuihe500 opened this issue Dec 10, 2022 · 7 comments

Comments

@cuihe500
Copy link

cuihe500 commented Dec 10, 2022

Describe the bug
我尝试切换到SpringBoot3.0并且使用NativeImages进行构建云原生的镜像。但是构建完毕后,在运行时报错

Environment

  • Alibaba RSocket Broker version: 1.1.4.
  • Operating System version: Windows 10
  • Java version:
    openjdk version "17.0.5" 2022-10-18
    OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
    OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

Steps to reproduce this issue

为了更好的复现这个问题,我写了一个Demo:
https://github.com/cuihe500/alibaba-rsocket-broker-native-image

1.执行 mvn -Pnative clean install

2.执行 mvn -Pnative spring-boot:build-image

3.执行 docker run --rm user-info-service:1.0-SNAPSHOT

user-info-service可以正常运行

4.执行 docker run --rm user-info-controller:1.0-SNAPSHOT

则出现报错:

2022-12-10 14:18:50 
2022-12-10 14:18:50   .   ____          _            __ _ _
2022-12-10 14:18:50  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2022-12-10 14:18:50 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2022-12-10 14:18:50  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2022-12-10 14:18:50   '  |____| .__|_| |_|_| |_\__, | / / / /
2022-12-10 14:18:50  =========|_|==============|___/=/_/_/_/
2022-12-10 14:18:50  :: Spring Boot ::                (v3.0.0)
2022-12-10 14:18:50 
2022-12-10 14:18:50 2022-12-10T06:18:50.927Z  INFO 1 --- [           main] o.e.u.UserInfoControllerApplication      : Starting AOT-processed UserInfoControllerApplication using Java 17.0.5 with PID 1 (/workspace/org.example.userinfocontroller.UserInfoControllerApplication started by cnb in /workspace)
2022-12-10 14:18:50 2022-12-10T06:18:50.927Z  INFO 1 --- [           main] o.e.u.UserInfoControllerApplication      : No active profile set, falling back to 1 default profile: "default"
2022-12-10 14:18:50 2022-12-10T06:18:50.931Z  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'rsocket-com.alibaba.spring.boot.rsocket.RSocketProperties' of type [com.alibaba.spring.boot.rsocket.RSocketProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-12-10 14:18:50 2022-12-10T06:18:50.931Z  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.spring.boot.rsocket.RSocketAutoConfiguration' of type [com.alibaba.spring.boot.rsocket.RSocketAutoConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-12-10 14:18:50 2022-12-10T06:18:50.941Z  INFO 1 --- [           main] c.a.r.loadbalance.LoadBalancedRSocket    : RST-300207: Update upstream connections for * with tcp://10.22.130.17:31999
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  WARN 1 --- [           main] .r.c.ReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userInfoController': Unsatisfied dependency expressed through method 'setUserInfoService' parameter 0: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  INFO 1 --- [           main] c.a.rsocket.upstream.UpstreamCluster     : RST-400201: Succeed to disconnect from the broker
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  INFO 1 --- [           main] c.a.r.upstream.UpstreamManagerImpl       : RST-400002: Succeed to close connection: *
2022-12-10 14:18:50 2022-12-10T06:18:50.954Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
2022-12-10 14:18:50 
2022-12-10 14:18:50 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userInfoController': Unsatisfied dependency expressed through method 'setUserInfoService' parameter 0: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolveArguments(AutowiredMethodArgumentsResolver.java:197) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolve(AutowiredMethodArgumentsResolver.java:145) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolve(AutowiredMethodArgumentsResolver.java:131) ~[na:na]
2022-12-10 14:18:50     at org.example.userinfocontroller.controller.UserInfoController__Autowiring.apply(UserInfoController__Autowiring.java:16) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:82) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.example.userinfocontroller.UserInfoControllerApplication.main(UserInfoControllerApplication.java:10) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1236) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolveArguments(AutowiredMethodArgumentsResolver.java:189) ~[na:na]
2022-12-10 14:18:50     ... 23 common frames omitted
2022-12-10 14:18:50 Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.example.common.service.UserInfoService] 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.
2022-12-10 14:18:50     at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na]
2022-12-10 14:18:50     at com.oracle.svm.core.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:171) ~[na:na]
2022-12-10 14:18:50     at [email protected]/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:47) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at [email protected]/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1037) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder.buildJdkProxy(RSocketRemoteServiceBuilder.java:185) ~[na:na]
2022-12-10 14:18:50     at com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder.build(RSocketRemoteServiceBuilder.java:163) ~[na:na]
2022-12-10 14:18:50     at org.example.config.EnableUserInfoServiceConfiguration.userInfoService(EnableUserInfoServiceConfiguration.java:19) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at org.example.config.EnableUserInfoServiceConfiguration__BeanDefinitions.lambda$getUserInfoServiceInstanceSupplier$0(EnableUserInfoServiceConfiguration__BeanDefinitions.java:29) ~[na:na]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:208) ~[na:na]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:59) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:47) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:220) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:208) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     ... 35 common frames omitted
2022-12-10 14:18:50

Expected Result

正常运行

Actual Result

在运行时报错:

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.eaip.common.service.UserInfoSqlService.UserInfoSqlService] 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.

以下是完整的运行报错:

2022-12-10 14:18:50 
2022-12-10 14:18:50   .   ____          _            __ _ _
2022-12-10 14:18:50  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2022-12-10 14:18:50 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2022-12-10 14:18:50  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2022-12-10 14:18:50   '  |____| .__|_| |_|_| |_\__, | / / / /
2022-12-10 14:18:50  =========|_|==============|___/=/_/_/_/
2022-12-10 14:18:50  :: Spring Boot ::                (v3.0.0)
2022-12-10 14:18:50 
2022-12-10 14:18:50 2022-12-10T06:18:50.927Z  INFO 1 --- [           main] o.e.u.UserInfoControllerApplication      : Starting AOT-processed UserInfoControllerApplication using Java 17.0.5 with PID 1 (/workspace/org.example.userinfocontroller.UserInfoControllerApplication started by cnb in /workspace)
2022-12-10 14:18:50 2022-12-10T06:18:50.927Z  INFO 1 --- [           main] o.e.u.UserInfoControllerApplication      : No active profile set, falling back to 1 default profile: "default"
2022-12-10 14:18:50 2022-12-10T06:18:50.931Z  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'rsocket-com.alibaba.spring.boot.rsocket.RSocketProperties' of type [com.alibaba.spring.boot.rsocket.RSocketProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-12-10 14:18:50 2022-12-10T06:18:50.931Z  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.spring.boot.rsocket.RSocketAutoConfiguration' of type [com.alibaba.spring.boot.rsocket.RSocketAutoConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-12-10 14:18:50 2022-12-10T06:18:50.941Z  INFO 1 --- [           main] c.a.r.loadbalance.LoadBalancedRSocket    : RST-300207: Update upstream connections for * with tcp://10.22.130.17:31999
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  WARN 1 --- [           main] .r.c.ReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userInfoController': Unsatisfied dependency expressed through method 'setUserInfoService' parameter 0: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  INFO 1 --- [           main] c.a.rsocket.upstream.UpstreamCluster     : RST-400201: Succeed to disconnect from the broker
2022-12-10 14:18:50 2022-12-10T06:18:50.953Z  INFO 1 --- [           main] c.a.r.upstream.UpstreamManagerImpl       : RST-400002: Succeed to close connection: *
2022-12-10 14:18:50 2022-12-10T06:18:50.954Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
2022-12-10 14:18:50 
2022-12-10 14:18:50 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userInfoController': Unsatisfied dependency expressed through method 'setUserInfoService' parameter 0: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolveArguments(AutowiredMethodArgumentsResolver.java:197) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolve(AutowiredMethodArgumentsResolver.java:145) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolve(AutowiredMethodArgumentsResolver.java:131) ~[na:na]
2022-12-10 14:18:50     at org.example.userinfocontroller.controller.UserInfoController__Autowiring.apply(UserInfoController__Autowiring.java:16) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:82) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[org.example.userinfocontroller.UserInfoControllerApplication:3.0.0]
2022-12-10 14:18:50     at org.example.userinfocontroller.UserInfoControllerApplication.main(UserInfoControllerApplication.java:10) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoService': Instantiation of supplied bean failed
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1236) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver.resolveArguments(AutowiredMethodArgumentsResolver.java:189) ~[na:na]
2022-12-10 14:18:50     ... 23 common frames omitted
2022-12-10 14:18:50 Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.example.common.service.UserInfoService] 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.
2022-12-10 14:18:50     at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na]
2022-12-10 14:18:50     at com.oracle.svm.core.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:171) ~[na:na]
2022-12-10 14:18:50     at [email protected]/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:47) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at [email protected]/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1037) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder.buildJdkProxy(RSocketRemoteServiceBuilder.java:185) ~[na:na]
2022-12-10 14:18:50     at com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder.build(RSocketRemoteServiceBuilder.java:163) ~[na:na]
2022-12-10 14:18:50     at org.example.config.EnableUserInfoServiceConfiguration.userInfoService(EnableUserInfoServiceConfiguration.java:19) ~[org.example.userinfocontroller.UserInfoControllerApplication:na]
2022-12-10 14:18:50     at org.example.config.EnableUserInfoServiceConfiguration__BeanDefinitions.lambda$getUserInfoServiceInstanceSupplier$0(EnableUserInfoServiceConfiguration__BeanDefinitions.java:29) ~[na:na]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:208) ~[na:na]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:59) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:47) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:220) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:208) ~[na:na]
2022-12-10 14:18:50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[org.example.userinfocontroller.UserInfoControllerApplication:6.0.2]
2022-12-10 14:18:50     ... 35 common frames omitted
2022-12-10 14:18:50

由于水平有限,第一次接触Native Images和SpringBoot3.0,不知哪里出问题,希望能得到帮助,万分感谢!!

@cuihe500
Copy link
Author

@linux-china 能麻烦您看一下问题所在吗?

@linux-china
Copy link
Collaborator

linux-china commented Dec 14, 2022

目前还支持Spring Boot 3的native-image适配。目前支持的native-image是基于spring native的 https://github.com/alibaba-rsocket-broker/ali-rsocket-graal-demo 很快会进行对应的适配。

如果第一次接触Native Images和SpringBoot3.0,还是从简单的开始,从官方的例子开始,这样不会出错,使用也简单。当然alibaba rsocket 和Spring Boot 3的native image适配,我会很快添加上。 上周刚发布Spring Boot 3的版本,等稳定后马上着手native image。

@cuihe500
Copy link
Author

目前还支持Spring Boot 3的native-image适配。目前支持的native-image是基于spring native的 https://github.com/alibaba-rsocket-broker/ali-rsocket-graal-demo 很快会进行对应的适配。

如果第一次接触Native Images和SpringBoot3.0,还是从简单的开始,从官方的例子开始,这样不会出错,使用也简单。当然alibaba rsocket 和Spring Boot 3的native image适配,我会很快添加上。 上周刚发布Spring Boot 3的版本,等稳定后马上着手native image。

好的 感谢您的回复与建议 期待支持native image的alibaba rsocket ;)

@linux-china
Copy link
Collaborator

@cuihe500
Copy link
Author

cuihe500 commented May 8, 2023

@cuihe500 请参考 https://github.com/alibaba-rsocket-broker/ali-rsocket-graal-boot3-demo

好的 收到 我去尝试一下 距离五个多月后在收到您的回复真的很开心 :)

@cuihe500
Copy link
Author

@cuihe500 请参考 https://github.com/alibaba-rsocket-broker/ali-rsocket-graal-boot3-demo

可以正确构建,但是运行时会出现该问题:
`2023-05-12T10:27:18.626+08:00 WARN 1803987 --- [ parallel-3] reactor.core.Exceptions : throwIfFatal detected a jvm fatal exception, which is thrown and logged below:

java.lang.ExceptionInInitializerError: null
at com.caucho.hessian.io.SerializerFactory.(SerializerFactory.java:127) ~[na:na]
at com.caucho.hessian.io.SerializerFactory.(SerializerFactory.java:120) ~[na:na]
at com.caucho.hessian.io.SerializerFactory.createDefault(SerializerFactory.java:151) ~[na:na]
at com.caucho.hessian.io.AbstractHessianOutput.findSerializerFactory(AbstractHessianOutput.java:107) ~[ali-rsocket-graal-boot3-demo:3.1.0]
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:463) ~[ali-rsocket-graal-boot3-demo:3.1.0]
at org.eaip.rsocket.encoding.impl.ObjectEncodingHandlerHessianImpl.encode(ObjectEncodingHandlerHessianImpl.java:31) ~[ali-rsocket-graal-boot3-demo:na]
at org.eaip.rsocket.encoding.impl.ObjectEncodingHandlerHessianImpl.encodingParams(ObjectEncodingHandlerHessianImpl.java:58) ~[ali-rsocket-graal-boot3-demo:na]
at org.eaip.rsocket.encoding.impl.RSocketEncodingFacadeImpl.encodingParams(RSocketEncodingFacadeImpl.java:58) ~[na:na]
at org.eaip.rsocket.invocation.RSocketRequesterRpcProxy.invoke(RSocketRequesterRpcProxy.java:179) ~[ali-rsocket-graal-boot3-demo:na]
at jdk.proxy4/jdk.proxy4.$Proxy131.getInstances(Unknown Source) ~[na:na]
at org.eaip.rsocket.upstream.UpstreamManagerImpl.lambda$monitorClusters$0(UpstreamManagerImpl.java:149) ~[ali-rsocket-graal-boot3-demo:na]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:386) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.publisher.FluxInterval$IntervalRunnable.run(FluxInterval.java:125) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.scheduler.PeriodicWorkerTask.call(PeriodicWorkerTask.java:59) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.scheduler.PeriodicWorkerTask.run(PeriodicWorkerTask.java:73) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
at [email protected]/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at [email protected]/java.lang.Thread.run(Thread.java:833) ~[ali-rsocket-graal-boot3-demo:na]
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775) ~[ali-rsocket-graal-boot3-demo:na]
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203) ~[na:na]
Caused by: com.caucho.hessian.HessianException: java.lang.NoSuchMethodException: java.sql.Date.(long)
at com.caucho.hessian.io.SqlDateDeserializer.(SqlDateDeserializer.java:69) ~[na:na]
at com.caucho.hessian.io.ContextSerializerFactory.(ContextSerializerFactory.java:487) ~[na:na]
... 23 common frames omitted
Caused by: java.lang.NoSuchMethodException: java.sql.Date.(long)
at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.lang.Class.getConstructor(DynamicHub.java:2271) ~[ali-rsocket-graal-boot3-demo:na]
at com.caucho.hessian.io.SqlDateDeserializer.(SqlDateDeserializer.java:67) ~[na:na]
... 24 common frames omitted

2023-05-12T10:27:18.627+08:00 ERROR 1803987 --- [ parallel-3] reactor.core.scheduler.Schedulers : Scheduler worker in group main failed with an uncaught exception

java.lang.ExceptionInInitializerError: null
at com.caucho.hessian.io.SerializerFactory.(SerializerFactory.java:127) ~[na:na]
at com.caucho.hessian.io.SerializerFactory.(SerializerFactory.java:120) ~[na:na]
at com.caucho.hessian.io.SerializerFactory.createDefault(SerializerFactory.java:151) ~[na:na]
at com.caucho.hessian.io.AbstractHessianOutput.findSerializerFactory(AbstractHessianOutput.java:107) ~[ali-rsocket-graal-boot3-demo:3.1.0]
at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:463) ~[ali-rsocket-graal-boot3-demo:3.1.0]
at org.eaip.rsocket.encoding.impl.ObjectEncodingHandlerHessianImpl.encode(ObjectEncodingHandlerHessianImpl.java:31) ~[ali-rsocket-graal-boot3-demo:na]
at org.eaip.rsocket.encoding.impl.ObjectEncodingHandlerHessianImpl.encodingParams(ObjectEncodingHandlerHessianImpl.java:58) ~[ali-rsocket-graal-boot3-demo:na]
at org.eaip.rsocket.encoding.impl.RSocketEncodingFacadeImpl.encodingParams(RSocketEncodingFacadeImpl.java:58) ~[na:na]
at org.eaip.rsocket.invocation.RSocketRequesterRpcProxy.invoke(RSocketRequesterRpcProxy.java:179) ~[ali-rsocket-graal-boot3-demo:na]
at jdk.proxy4/jdk.proxy4.$Proxy131.getInstances(Unknown Source) ~[na:na]
at org.eaip.rsocket.upstream.UpstreamManagerImpl.lambda$monitorClusters$0(UpstreamManagerImpl.java:149) ~[ali-rsocket-graal-boot3-demo:na]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:386) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.publisher.FluxInterval$IntervalRunnable.run(FluxInterval.java:125) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.scheduler.PeriodicWorkerTask.call(PeriodicWorkerTask.java:59) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at reactor.core.scheduler.PeriodicWorkerTask.run(PeriodicWorkerTask.java:73) ~[ali-rsocket-graal-boot3-demo:3.5.5]
at [email protected]/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
at [email protected]/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at [email protected]/java.lang.Thread.run(Thread.java:833) ~[ali-rsocket-graal-boot3-demo:na]
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775) ~[ali-rsocket-graal-boot3-demo:na]
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203) ~[na:na]
Caused by: com.caucho.hessian.HessianException: java.lang.NoSuchMethodException: java.sql.Date.(long)
at com.caucho.hessian.io.SqlDateDeserializer.(SqlDateDeserializer.java:69) ~[na:na]
at com.caucho.hessian.io.ContextSerializerFactory.(ContextSerializerFactory.java:487) ~[na:na]
... 23 common frames omitted
Caused by: java.lang.NoSuchMethodException: java.sql.Date.(long)
at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[ali-rsocket-graal-boot3-demo:na]
at [email protected]/java.lang.Class.getConstructor(DynamicHub.java:2271) ~[ali-rsocket-graal-boot3-demo:na]
at com.caucho.hessian.io.SqlDateDeserializer.(SqlDateDeserializer.java:67) ~[na:na]
... 24 common frames omitted

`
目前考虑应该是hessian序列化的问题 @linux-china

@linux-china
Copy link
Collaborator

@cuihe500 能否看一下你的java class类,能否将那个 java.sql.Date类型的字段删除后看一下? 如果方便的话,将对应的class能否贴一下,我看一下。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants