Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dubbo使用apollo做动态配置中心并使用namespace对应配置文件的存储模型出错 #5257

Closed
makingtime opened this issue Oct 29, 2019 · 3 comments
Milestone

Comments

@makingtime
Copy link

makingtime commented Oct 29, 2019

  • [√] I have searched the issues of this repository and believe that this is not a duplicate.
  • [√] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.4.1
  • Operating System version: Windows 10 专业版 1809
  • Java version: 1.8.0.191
  • Apollo version: 1.5.0

Steps to reproduce this issue

根据2.7.4.1的release note:https://github.com/apache/dubbo/releases/tag/dubbo-2.7.4
PR:#5105
issue:#3266

我在apollo中使用了一个namespace对应一个配置文件的存储和组织模型,比如dubbo namespace(类型:properties),对应dubbo.properties,里面的配置项目是dubbo.properties中的配置项目,而不是之前的一个key:dubbo.properties里面存储了整个dubbo.properties的内容

具体配置:apolloconfig/apollo#2702

Expected Result

dubbo consumer 正常启动

Actual Result

最后应用异常退出

2019-10-28 18:02:46.676 [main] INFO  org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-28 18:02:46.678 [main] INFO  org.apache.dubbo.spring.boot.context.event.AwaitingNonWebApplicationListener -  [Dubbo] Current Spring Boot Application is about to shutdown...
2019-10-28 18:02:46.692 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubboConsumerController': Injection of @Reference dependencies is failed; nested exception is java.lang.IllegalStateException: No registry config found or it's not a valid config! The registry config is: <dubbo:registry valid="false" zookeeperProtocol="false" prefix="dubbo.registry" />
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:150) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1416) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at com.test.consumer_a.DubboConsumerApplication.main(DubboConsumerApplication.java:13) [classes/:?]
Caused by: java.lang.IllegalStateException: No registry config found or it's not a valid config! The registry config is: <dubbo:registry valid="false" zookeeperProtocol="false" prefix="dubbo.registry" />
	at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:203) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:378) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:329) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:250) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.getOrCreateProxy(ReferenceAnnotationBeanPostProcessor.java:246) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:143) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.getInjectedObject(AnnotationInjectedBeanPostProcessor.java:359) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement.inject(AnnotationInjectedBeanPostProcessor.java:539) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:146) ~[dubbo-2.7.4.1.jar:2.7.4.1]
	... 17 more
Disconnected from the target VM, address: '127.0.0.1:55529', transport: 'socket'

Process finished with exit code 1

我在com.ctrip.framework.apollo.internals.RemoteConfigRepository构造函数第一行下了断点,发现dubbo还是会传入dubbo.properties作为namespace来查询配置,具体的堆栈信息如下:

<init>:79, RemoteConfigRepository (com.ctrip.framework.apollo.internals)
createRemoteConfigRepository:77, DefaultConfigFactory (com.ctrip.framework.apollo.spi)
createLocalConfigRepository:73, DefaultConfigFactory (com.ctrip.framework.apollo.spi)
createConfigFile:47, DefaultConfigFactory (com.ctrip.framework.apollo.spi)
getConfigFile:58, DefaultConfigManager (com.ctrip.framework.apollo.internals)
getConfigFile:65, ConfigService (com.ctrip.framework.apollo)
getProperties:155, ApolloDynamicConfiguration (org.apache.dubbo.configcenter.support.apollo)
getProperties:110, DynamicConfiguration (org.apache.dubbo.configcenter)
prepareEnvironment:291, AbstractInterfaceConfig (org.apache.dubbo.config)
startConfigCenter:280, AbstractInterfaceConfig (org.apache.dubbo.config)
checkAndUpdateSubConfigs:220, ReferenceConfig (org.apache.dubbo.config)
get:244, ReferenceConfig (org.apache.dubbo.config)
getOrCreateProxy:246, ReferenceAnnotationBeanPostProcessor (org.apache.dubbo.config.spring.beans.factory.annotation)
doGetInjectedBean:143, ReferenceAnnotationBeanPostProcessor (org.apache.dubbo.config.spring.beans.factory.annotation)
getInjectedObject:359, AnnotationInjectedBeanPostProcessor (org.apache.dubbo.config.spring.beans.factory.annotation)
inject:539, AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement (org.apache.dubbo.config.spring.beans.factory.annotation)
inject:90, InjectionMetadata (org.springframework.beans.factory.annotation)
postProcessPropertyValues:146, AnnotationInjectedBeanPostProcessor (org.apache.dubbo.config.spring.beans.factory.annotation)
populateBean:1416, AbstractAutowireCapableBeanFactory (org.springframework.beans.factory.support)
doCreateBean:592, AbstractAutowireCapableBeanFactory (org.springframework.beans.factory.support)
createBean:515, AbstractAutowireCapableBeanFactory (org.springframework.beans.factory.support)
lambda$doGetBean$0:320, AbstractBeanFactory (org.springframework.beans.factory.support)
getObject:-1, 1031775150 (org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$141)
getSingleton:222, DefaultSingletonBeanRegistry (org.springframework.beans.factory.support)
doGetBean:318, AbstractBeanFactory (org.springframework.beans.factory.support)
getBean:199, AbstractBeanFactory (org.springframework.beans.factory.support)
preInstantiateSingletons:845, DefaultListableBeanFactory (org.springframework.beans.factory.support)
finishBeanFactoryInitialization:877, AbstractApplicationContext (org.springframework.context.support)
refresh:549, AbstractApplicationContext (org.springframework.context.support)
refresh:141, ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context)
refresh:743, SpringApplication (org.springframework.boot)
refreshContext:390, SpringApplication (org.springframework.boot)
run:312, SpringApplication (org.springframework.boot)
run:1214, SpringApplication (org.springframework.boot)
run:1203, SpringApplication (org.springframework.boot)
main:13, DubboConsumerApplication (com.test.consumer_a)

getProperties:155, ApolloDynamicConfiguration (org.apache.dubbo.configcenter.support.apollo)这里传入的是:ConfigService.getConfigFile("dubbo.properties", ConfigFileFormat.Properties)

而正常的应该是: ConfigService.getConfigFile("dubbo", ConfigFileFormat.Properties)

@makingtime
Copy link
Author

makingtime commented Oct 31, 2019

我目前暂时在org.apache.dubbo.configcenter.support.apollo.ApolloDynamicConfigurationgetProperties方法最开始加了几行代码以支持dubbo namespace的存储模型:

        if(key.endsWith(ConfigFileFormat.Properties.getValue())) {
            key = key.substring(0, key.indexOf(ConfigFileFormat.Properties.getValue()) - 1);
        }

@nobodyiam
Copy link
Contributor

I think we could review the original PR and apply some fix if necessary.

@chickenlj
Copy link
Contributor

Hi @makingtime , I am afraid that the 2.7.4.1dubbo-configcenter-apollo could not work properly with Apollo. Please see the #5298 for why we did the change and what we plan to do to fix it in the next version.

@chickenlj chickenlj added this to the 2.7.5 milestone Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants