Closed imgoby closed 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
this is my demo project: https://github.com/imgoby/spring-cloud-alibaba-graalvm/tree/main/spring-cloud-alibaba-consul-dubbo-provider
it run failed.
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×tamp=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®ister=false®istry=spring-cloud&release=3.3.0-beta.1×tamp=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×tamp=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×tamp=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®ister=false&release=3.3.0-beta.1×tamp=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×tamp=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
please use native-image. (1) mvn clean package native:compile (2) run binary file
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>
The problem still exists. spring-boot version is 3.0.5. Why?
exec mvn dependency:tree | grep spring
to see spring dependencies versions
[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
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
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.
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": [ ]
}
]
}
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.
But I don't know why they don't automatically generate.
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=
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
Is this the best method?
Is this the best method?
I think it is ok
Thank you.
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.
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?
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'.
Wouldn't upgrading the spring boot version fix that?
Wouldn't upgrading the spring boot version fix that?
I have tried spring-boot the latest 3.2.0, the problem still exists
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
@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
Environment