alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.07k stars 12.81k forks source link

SpringGateway Nacos Refresh Exception #12128

Closed onekr-billy closed 4 months ago

onekr-billy commented 4 months ago

Describe the bug 集成在SpringCloudGateway项目中,并开启了 热更新@RefreshScope , 当在Nacos服务端修改配置后,无法拉取到最新的配置,并且控制台会报错 Integrated in the SpringCloudGateway project, and hot update @RefreshScope is enabled. When the configuration is modified on the Nacos server, the latest configuration cannot be pulled, and the console will report an error.

Expected behavior 预期应该是不要报错,并且获得修改后的配置 The expectation should be to not report an error and obtain the modified configuration.

Actually behavior

How to Reproduce Steps to reproduce the behavior:

  1. 集成Nacos到SpringGateway中,并订阅配置,比如 user.age: 13

  2. 启动项目

  3. 在Nacos管理面版修改配置,比如 user.age: 14

  4. 观察启动的项目控制台的输出以及 通过api查看是否拉取到最新的值 http://localhost:8080/user

  5. 控制台出现错误了

  6. Integrate Nacos into SpringGateway and subscribe to the configuration, such as user.age: 13

  7. Start the project

  8. Modify the configuration in the Nacos management panel, such as user.age: 14

  9. Observe the output of the started project console and check whether the latest value is pulled through the api http://localhost:8080/user

  10. An error occurred in the console

org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'httpClientProperties': Could not bind properties to 'HttpClientProperties' : prefix=spring.cloud.gateway.httpclient, ignoreInvalidFields=false, ignoreUnknownFields=true at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:99) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:79) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:420) ~[spring-beans-6.0.4.jar:6.0.4] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1743) ~[spring-beans-6.0.4.jar:6.0.4] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:411) ~[spring-beans-6.0.4.jar:6.0.4] at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:138) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:97) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:85) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.onApplicationEvent(ConfigurationPropertiesRebinder.java:170) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.onApplicationEvent(ConfigurationPropertiesRebinder.java:53) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.cloud.context.refresh.ContextRefresher.refreshEnvironment(ContextRefresher.java:103) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.context.refresh.ContextRefresher.refresh(ContextRefresher.java:94) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.endpoint.event.RefreshEventListener.handle(RefreshEventListener.java:72) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.cloud.endpoint.event.RefreshEventListener.onApplicationEvent(RefreshEventListener.java:61) ~[spring-cloud-context-4.0.0-RC2.jar:4.0.0-RC2] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring-context-6.0.4.jar:6.0.4] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring-context-6.0.4.jar:6.0.4] at com.alibaba.cloud.nacos.refresh.NacosContextRefresher$1.innerReceive(NacosContextRefresher.java:118) ~[spring-cloud-starter-alibaba-nacos-config-2022.0.0.0-RC2.jar:2022.0.0.0-RC2] at com.alibaba.nacos.api.config.listener.AbstractSharedListener.receiveConfigInfo(AbstractSharedListener.java:40) ~[nacos-client-2.2.1.jar:na] at com.alibaba.nacos.client.config.impl.CacheData.lambda$safeNotifyListener$1(CacheData.java:334) ~[nacos-client-2.2.1.jar:na] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na] at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) ~[na:na] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na] Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.cloud.gateway.httpclient.ssl.key-manager-factory.provider' to java.security.Provider at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:387) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:347) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:472) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.ValueObjectBinder$ConstructorParameter.bind(ValueObjectBinder.java:314) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.ValueObjectBinder.bind(ValueObjectBinder.java:76) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:476) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:576) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:474) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:414) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:472) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:98) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:86) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:62) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:476) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:576) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:474) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:414) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:472) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:98) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:86) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:62) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:476) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:576) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:474) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:414) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:332) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:262) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:249) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:93) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:96) ~[spring-boot-3.0.2.jar:3.0.2] ... 32 common frames omitted Caused by: java.lang.IllegalArgumentException: Could not instantiate Map type: java.security.Provider at org.springframework.core.CollectionFactory.createMap(CollectionFactory.java:321) ~[spring-core-6.0.4.jar:6.0.4] at org.springframework.core.CollectionFactory.createMap(CollectionFactory.java:265) ~[spring-core-6.0.4.jar:6.0.4] at org.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:57) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:56) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$3(Binder.java:438) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:438) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:399) ~[spring-boot-3.0.2.jar:3.0.2] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343) ~[spring-boot-3.0.2.jar:3.0.2] ... 66 common frames omitted Caused by: java.lang.NoSuchMethodException: java.security.Provider.<init>() at java.base/java.lang.Class.getConstructor0(Class.java:3585) ~[na:na] at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754) ~[na:na] at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:185) ~[spring-core-6.0.4.jar:6.0.4] at org.springframework.core.CollectionFactory.createMap(CollectionFactory.java:318) ~[spring-core-6.0.4.jar:6.0.4] ... 74 common frames omitted

Desktop (please complete the following information):

Additional context 导致问题的原因是 引入了 spring-boot-starter-actuator 包导致的,去掉后就正常了

gatewayDemo.zip

KomachiSion commented 4 months ago

问题应该与nacos无关, 是spring cloud或spring boot中的类冲突导致。

KomachiSion commented 4 months ago

可以把信息提交到SCA社区,看下是哪里冲突导致的。