apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.5k stars 26.43k forks source link

dubbo native-image run failed. #13434

Closed imgoby closed 11 months ago

imgoby commented 11 months ago

Environment

3.3.0-beta.1 This is Exception information: ``` 2023-11-29T09:15:49.522+08:00 INFO 5058 --- [ main] d.s.b.c.e.WelcomeLogoApplicationListener : [DUBBO] :: Dubbo (v3.3.0-beta.1) : https://github.com/apache/dubbo :: Discuss group : dev@dubbo.apache.org , dubbo version: 3.3.0-beta.1, current host: 192.168.0.219 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.0.0) 2023-11-29T09:15:49.528+08:00 ERROR 5058 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.cglib.core.CodeGenerationException: java.lang.NoSuchMethodException-->org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration$$SpringCGLIB$$0.CGLIB$SET_THREAD_CALLBACKS([Lorg.springframework.cglib.proxy.Callback;) at org.springframework.cglib.proxy.Enhancer$EnhancerFactoryData.(Enhancer.java:506) at org.springframework.cglib.proxy.Enhancer.wrapCachedClass(Enhancer.java:801) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:114) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:111) at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:55) at java.base@17.0.5/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:62) at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:35) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:137) at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:322) at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:567) at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:412) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:138) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:109) at org.springframework.context.annotation.ConfigurationClassUtils.initializeConfigurationClass(ConfigurationClassUtils.java:81) at org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration__BeanDefinitions.getDubboRelaxedBindingAutoConfigurationBeanDefinition(DubboRelaxedBinding2AutoConfiguration__BeanDefinitions.java:24) at com.yuhoutian.demo.provider.ProviderApplication__BeanFactoryRegistrations.registerBeanDefinitions(ProviderApplication__BeanFactoryRegistrations.java:378) at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.initialize(ProviderApplication__ApplicationContextInitializer.java:26) at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.initialize(ProviderApplication__ApplicationContextInitializer.java:19) at org.springframework.context.aot.AotApplicationContextInitializer.initialize(AotApplicationContextInitializer.java:72) at org.springframework.context.aot.AotApplicationContextInitializer.lambda$forInitializerClasses$0(AotApplicationContextInitializer.java:61) at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:603) at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:383) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) at com.yuhoutian.demo.provider.ProviderApplication.main(ProviderApplication.java:33) Caused by: java.lang.NoSuchMethodException: org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration$$SpringCGLIB$$0.CGLIB$SET_THREAD_CALLBACKS([Lorg.springframework.cglib.proxy.Callback;) at java.base@17.0.5/java.lang.Class.getDeclaredMethod(DynamicHub.java:2675) at org.springframework.cglib.proxy.Enhancer.getCallbacksSetter(Enhancer.java:907) at org.springframework.cglib.proxy.Enhancer$EnhancerFactoryData.(Enhancer.java:495) ... 26 common frames omitted ```
FoghostCn commented 11 months ago

pls assign to me

@imgoby I can't reproduce,please provide more information According to the issue template, and application.yaml is also needed, if you can create a demo project it would be better

I have a dubbo native demo project, maybe you can take a look https://github.com/FoghostCn/dubbo-native/tree/master/spring-triple

imgoby commented 11 months ago

this is my demo project: https://github.com/imgoby/spring-cloud-alibaba-graalvm/tree/main/spring-cloud-alibaba-consul-dubbo-provider

it run failed.

sjcsjc123 commented 11 months ago

this is my demo project: https://github.com/imgoby/spring-cloud-alibaba-graalvm/tree/main/spring-cloud-alibaba-consul-dubbo-provider

it run failed.

I ran your demo project and it was successful.

2023-11-29T20:17:28.292+08:00  INFO 9880 --- [           main] o.a.d.r.c.m.ServiceInstanceMetadataUtils :  [DUBBO] Start registering instance address to registry., dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.308+08:00  INFO 9880 --- [           main] org.apache.dubbo.metadata.MetadataInfo   :  [DUBBO] metadata revision changed: null -> 2f13f57d28b709ccf344887633202b3c, app: spring-cloud-alibaba-consul-dubbo-provider, services: 1, dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.320+08:00  INFO 9880 --- [           main] o.a.d.c.d.DefaultApplicationDeployer     :  [DUBBO] Dubbo Application[1.1](spring-cloud-alibaba-consul-dubbo-provider) is ready., dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.321+08:00  INFO 9880 --- [           main] o.a.d.r.integration.RegistryProtocol     :  [DUBBO] Registered dubbo service com.yuhoutian.demo.api.DemoService url dubbo://198.18.0.1:20881/com.yuhoutian.demo.api.DemoService?application=spring-cloud-alibaba-consul-dubbo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.yuhoutian.demo.api.DemoService&methods=sayHello&prefer.serialization=fastjson2,hessian2&release=3.3.0-beta.1&service-name-mapping=true&side=provider&timestamp=1701260248243 to registry service-discovery-registry://localhost:9090/org.apache.dubbo.registry.RegistryService?application=spring-cloud-alibaba-consul-dubbo-provider&dubbo=2.0.2&executor-management-mode=isolation&file-cache=true&pid=9880&qos.enable=false&register=false&registry=spring-cloud&release=3.3.0-beta.1&timestamp=1701260248242, dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.322+08:00  INFO 9880 --- [           main] c.a.c.dubbo.registry.DubboCloudRegistry  :  [DUBBO] Register: dubbo://198.18.0.1:20881/com.yuhoutian.demo.api.DemoService?application=spring-cloud-alibaba-consul-dubbo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.yuhoutian.demo.api.DemoService&methods=sayHello&prefer.serialization=fastjson2,hessian2&release=3.3.0-beta.1&service-name-mapping=true&side=provider&timestamp=1701260248243, dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.331+08:00  INFO 9880 --- [           main] o.a.d.r.integration.RegistryProtocol     :  [DUBBO] Registered dubbo service com.yuhoutian.demo.api.DemoService url dubbo://198.18.0.1:20881/com.yuhoutian.demo.api.DemoService?application=spring-cloud-alibaba-consul-dubbo-provider&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.yuhoutian.demo.api.DemoService&methods=sayHello&prefer.serialization=fastjson2,hessian2&release=3.3.0-beta.1&service-name-mapping=true&side=provider&timestamp=1701260248243 to registry spring-cloud://localhost:9090/org.apache.dubbo.registry.RegistryService?application=spring-cloud-alibaba-consul-dubbo-provider&dubbo=2.0.2&executor-management-mode=isolation&file-cache=true&pid=9880&qos.enable=false&register=false&release=3.3.0-beta.1&timestamp=1701260248242, dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.331+08:00  INFO 9880 --- [           main] org.apache.dubbo.metadata.MetadataInfo   :  [DUBBO] metadata revision changed: 2f13f57d28b709ccf344887633202b3c -> 6eec47d909ae33804ba15a78228e2fb3, app: spring-cloud-alibaba-consul-dubbo-provider, services: 2, dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.332+08:00  INFO 9880 --- [           main] o.a.d.r.client.AbstractServiceDiscovery  :  [DUBBO] Metadata of instance changed, updating instance with revision 6eec47d909ae33804ba15a78228e2fb3., dubbo version: 3.3.0-beta.1, current host: 198.18.0.1
2023-11-29T20:17:28.338+08:00  INFO 9880 --- [           main] c.y.demo.provider.ProviderApplication    : Started ProviderApplication in 3.608 seconds (process running for 3.978)
2023-11-29T20:17:28.353+08:00  INFO 9880 --- [           main] o.s.c.c.s.ConsulServiceRegistry          : Registering service with consul: NewService{id='spring-cloud-alibaba-consul-dubbo-provider-192-168-0-180-9998', name='spring-cloud-alibaba-consul-dubbo-provider', tags=[dubbo.metadata-service.urls=[ "dubbo://198.18.0.1:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=spring-cloud-alibaba-consul-dubbo-provider&background=false&bind.ip=198.18.0.1&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=isolation&file-cache=true&generic=false&group=spring-cloud-alibaba-consul-dubbo-provider&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllExportedURLs,getAllServiceKeys,getExportedURLs,getServiceRestMetadata&pid=9880&qos.enable=false&release=3.3.0-beta.1&revision=1.0.0&service-name-mapping=true&side=provider&timestamp=1701260247937&version=1.0.0" ], dubbo.protocols.dubbo.port=20881, dubbo.metadata.revision=37ABF43264CD90D35112B9112A0B43CA, secure=false], address='192.168.0.180', meta={secure=false}, port=9998, enableTagOverride=null, check=Check{script='null', dockerContainerID='null', shell='null', interval='10s', ttl='null', http='http://192.168.0.180:9998/actuator/info', method='null', header={}, tcp='null', timeout='null', deregisterCriticalServiceAfter='3m', tlsSkipVerify=null, status='null', grpc='null', grpcUseTLS=null}, checks=null}
2023-11-29T20:17:28.584+08:00  INFO 9880 --- [on(5)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-11-29T20:17:28.584+08:00  INFO 9880 --- [on(5)-127.0.0.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-11-29T20:17:28.585+08:00  INFO 9880 --- [on(5)-127.0.0.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
imgoby commented 11 months ago

please use native-image. (1) mvn clean package native:compile (2) run binary file

FoghostCn commented 11 months ago

It seem's like spring version problem, we expect spring-boot version is 3.0.5, but actually it is 3.0.0

put spring-boot-dependencies dependencyManagement above spring-cloud-build-dependencies will resolve the problem, like this:

          <!-- Spring Dependencies -->
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-dependencies</artifactId>
              <version>${spring-boot.version}</version>
              <type>pom</type>
              <scope>import</scope>
          </dependency>
          <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-build-dependencies</artifactId>
              <version>${spring-cloud-build.version}</version>
              <type>pom</type>
              <scope>import</scope>
          </dependency>
imgoby commented 11 months ago

The problem still exists. spring-boot version is 3.0.5. Why? image

image

FoghostCn commented 11 months ago

exec mvn dependency:tree | grep spring to see spring dependencies versions

imgoby commented 11 months ago
[INFO] ------< com.yuhoutian:spring-cloud-alibaba-consul-dubbo-provider >------
[INFO] Building spring-cloud-alibaba-consul-dubbo-provider 2022.0.0.0     [4/5]
[INFO]   from spring-cloud-alibaba-consul-dubbo-provider/pom.xml
[INFO] --- dependency:2.8:tree (default-cli) @ spring-cloud-alibaba-consul-dubbo-provider ---
[INFO] com.yuhoutian:spring-cloud-alibaba-consul-dubbo-provider:jar:2022.0.0.0
[INFO] +- com.yuhoutian:spring-cloud-alibaba-consul-dubbo-api:jar:2022.0.0.0:compile
[INFO] +- org.apache.dubbo:dubbo-spring-boot-starter:jar:3.3.0-beta.1:compile
[INFO] |  \- org.apache.dubbo:dubbo-spring-boot-autoconfigure:jar:3.3.0-beta.1:compile
[INFO] |     \- org.apache.dubbo:dubbo-spring-boot-autoconfigure-compatible:jar:3.3.0-beta.1:compile
[INFO] +- org.apache.dubbo:dubbo-zookeeper-curator5-spring-boot-starter:jar:3.3.0-beta.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:3.0.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:3.0.5:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:3.0.5:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:3.0.5:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.0.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:3.0.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.0.5:compile
[INFO] |  +- org.springframework:spring-web:jar:6.0.7:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:6.0.7:compile
[INFO] |     +- org.springframework:spring-aop:jar:6.0.7:compile
[INFO] |     \- org.springframework:spring-expression:jar:6.0.7:compile
[INFO] +- org.apache.dubbo:dubbo-config-spring6:jar:3.3.0-beta.1:compile
[INFO] |  +- org.apache.dubbo:dubbo-config-spring:jar:3.3.0-beta.1:compile
[INFO] |  |  \- com.alibaba.spring:spring-context-support:jar:1.0.11:compile
[INFO] |  +- org.springframework:spring-beans:jar:6.0.7:compile
[INFO] |  +- org.springframework:spring-core:jar:6.0.7:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:6.0.7:compile
[INFO] |  \- org.springframework:spring-context:jar:6.0.7:compile
[INFO] +- com.yuhoutian:spring-cloud-alibaba-starter-dubbo:jar:2022.0.0.0:compile
[INFO] |  +- com.alibaba.cloud:spring-cloud-alibaba-commons:jar:2022.0.0.0:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-openfeign-core:jar:4.0.0:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-aop:jar:3.0.5:compile
[INFO] |  |  \- io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:3.0.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:3.0.5:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:3.0.5:compile
[INFO] \- org.springframework.cloud:spring-cloud-starter-consul-discovery:jar:4.0.0:compile
[INFO]    +- org.springframework.cloud:spring-cloud-starter-consul:jar:4.0.0:compile
[INFO]    |  +- org.springframework.cloud:spring-cloud-starter:jar:4.0.0:compile
[INFO]    |  |  +- org.springframework.cloud:spring-cloud-context:jar:4.0.0:compile
[INFO]    |  |  |  \- org.springframework.security:spring-security-crypto:jar:6.0.2:compile
[INFO]    |  |  +- org.springframework.cloud:spring-cloud-commons:jar:4.0.0:compile
[INFO]    |  |  \- org.springframework.security:spring-security-rsa:jar:1.0.11.RELEASE:compile
[INFO]    |  +- org.springframework.cloud:spring-cloud-consul-core:jar:4.0.0:compile
[INFO]    |  |  \- org.springframework.boot:spring-boot-starter-validation:jar:3.0.5:compile
[INFO]    +- org.springframework.cloud:spring-cloud-consul-discovery:jar:4.0.0:compile
[INFO]    \- org.springframework.cloud:spring-cloud-starter-loadbalancer:jar:4.0.0:compile
[INFO]       +- org.springframework.cloud:spring-cloud-loadbalancer:jar:4.0.0:compile
[INFO]       +- org.springframework.boot:spring-boot-starter-cache:jar:3.0.5:compile
[INFO]       |  \- org.springframework:spring-context-support:jar:6.0.7:compile
FoghostCn commented 11 months ago

I have pulled you lastest code and can't reproduce,just got

2023-11-30T18:05:14.233+08:00 ERROR 72720 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.io.UncheckedIOException: java.io.FileNotFoundException: class path resource [META-INF/dubbo/default/actuator-endpoints.properties] cannot be opened because it does not exist
        at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.processPropertySources(ProviderApplication__ApplicationContextInitializer.java:39)
        at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.initialize(ProviderApplication__ApplicationContextInitializer.java:25)
        at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.initialize(ProviderApplication__ApplicationContextInitializer.java:19)
        at org.springframework.context.aot.AotApplicationContextInitializer.initialize(AotApplicationContextInitializer.java:72)
        at org.springframework.context.aot.AotApplicationContextInitializer.lambda$forInitializerClasses$0(AotApplicationContextInitializer.java:61)
        at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:605)
        at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:385)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:309)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
        at com.yuhoutian.demo.provider.ProviderApplication.main(ProviderApplication.java:33)
Caused by: java.io.FileNotFoundException: class path resource [META-INF/dubbo/default/actuator-endpoints.properties] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:211)
        at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:160)
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:100)
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:74)
        at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:60)
        at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:67)
        at org.springframework.core.io.support.DefaultPropertySourceFactory.createPropertySource(DefaultPropertySourceFactory.java:37)
        at org.springframework.core.io.support.PropertySourceProcessor.processPropertySource(PropertySourceProcessor.java:87)
        at com.yuhoutian.demo.provider.ProviderApplication__ApplicationContextInitializer.processPropertySources(ProviderApplication__ApplicationContextInitializer.java:37)
        ... 10 common frames omitted

missing some config file, not the same error, compile again to see if it still happen

imgoby commented 11 months ago

It has been rolled back to last night's version. and set the dependency as follow:

<!-- Spring Dependencies -->
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-dependencies</artifactId>
              <version>${spring-boot.version}</version>
              <type>pom</type>
              <scope>import</scope>
          </dependency>
          <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-build-dependencies</artifactId>
              <version>${spring-cloud-build.version}</version>
              <type>pom</type>
              <scope>import</scope>
          </dependency>

You can try it again.

FoghostCn commented 11 months ago

indeed this issue is related to spring, you can open an issue there, https://github.com/spring-projects/spring-framework

or you can manually add a reflect config to src/main/resources/META-INF/native-image/reflect-config.json,such as below

{
    "name": "org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration$$SpringCGLIB$$0",
    "allDeclaredFields": true,
    "allDeclaredConstructors": true,
    "allDeclaredMethods": true,
    "queriedMethods": [
      {
        "name": "<init>",
        "parameterTypes": [ ]
      }
    ]
  }
imgoby commented 11 months ago

Thank you.You are right.I should add reflect-config.json、resource-config.json、proxy-config.json to the dir: src\main\resources\META-INF\native-image.It 's OK now.

see here: https://github.com/imgoby/spring-cloud-alibaba-graalvm/tree/main/spring-cloud-alibaba-starter-dubbo/src/main/resources/META-INF/native-image

But I don't know why they don't automatically generate.

imgoby commented 11 months ago

The summary is as follows:

Q: java.io.UncheckedIOException: java.io.FileNotFoundException: class path resource [META-INF/dubbo/default/actuator-endpoints.properties] cannot be opened because it does not exist A: set src\main\resources\META-INF\native-image\resource-config.json

Q: Caused by: java.lang.ClassNotFoundException: com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory A: set src\main\resources\META-INF\native-image\reflect-config.json

Q: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignTargeter': Proxy class defined by interfaces [interface org.springframework.cloud.openfeign.Targeter] 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.

A: set src\main\resources\META-INF\native-image\proxy-config.json

Q: Description:

The dependencies of some of the beans in the application context form a cycle:

targeterBeanPostProcessor ↓ com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository (field private com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.dubboMetadataConfigServiceProxy) ↓ com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy ┌─────┐ | com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration (field private com.alibaba.cloud.dubbo.metadata.resolver.MetadataResolver com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration.metadataResolver) └─────┘

A: (1)add @Lazy to java source: @Lazy @Autowired private MetadataResolver metadataResolver;

 (2)  application.yml

spring: main: allow-bean-definition-overriding: true allow-circular-references: true

imgoby commented 11 months ago

Is this the best method?

FoghostCn commented 11 months ago

Is this the best method?

I think it is ok

imgoby commented 11 months ago

Thank you.

CrazyHZM commented 11 months ago

Thank you. You are right. I should add reflect-config. json、resource-config. json、proxy-config. json to the dir: src\main\resources\META-INF\native-image.It's OK now.

See here: https://github.com/imgoby/spring-cloud-alibaba-graalvm/tree/main/spring-cloud-alibaba-starter-dubbo/src/main/resources/META-INF/native-image

But I wonder why they don't automatically generate.

We expect AutoConfiguration to be able to generate confg.json by spring. According to the discussion above, is it a version issue?

FoghostCn commented 11 months ago

I see the log of spring aot, but I'm not sure why

WARN 80761 --- [main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static' and/or marking the containing configuration class as 'proxyBeanMethods=false'.
WARN 80761 --- [main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static' and/or marking the containing configuration class as 'proxyBeanMethods=false'.
CrazyHZM commented 11 months ago

Wouldn't upgrading the spring boot version fix that?

FoghostCn commented 11 months ago

Wouldn't upgrading the spring boot version fix that?

I have tried spring-boot the latest 3.2.0, the problem still exists

FoghostCn commented 11 months ago

spring log suggest to set

@Configuration(
    proxyBeanMethods = false
)

to org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration and org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration, but we have to upgrade springboot to 3.x and spring-context to 6.x first

FoghostCn commented 11 months ago

@CrazyHZM @imgoby

comment below config the problem disappeared, I don't known whether it have some side effect

dubbo:
#  scan:
#    base-packages: com.yuhoutian.demo.provider