Environment
- Dubbo version: 2.7.6-SNAPSHOT(aliyun maven镜像,也用源码的 2.7.6.release分支测试过)
- Operating System version: win10
- Java version: 1.8.0_171
Steps to reproduce this issue
测试代码:https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-nacos/dubbo-samples-nacos-registry
dubbo版本修改为"2.7.6.SNAPSHOT"
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
Actual Result
(IP地址手动改成了 127.0.0.1)
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'annotatedConsumer': Injection of @Reference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service org.apache.dubbo.samples.api.GreetingService. No provider available for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 from the url nacos://localhost:8848/org.apache.dubbo.registry.RegistryService?application=nacos-registry-demo-consumer&dubbo=2.0.2&init=false&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=19028®ister.ip=127.0.0.1&release=2.7.6-SNAPSHOT&revision=1.0.0&side=consumer&sticky=false&timeout=3000×tamp=1584584637337&version=1.0.0 to the consumer 127.0.0.1 use dubbo version 2.7.6-SNAPSHOT
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
at org.apache.dubbo.samples.ConsumerBootstrap.main(ConsumerBootstrap.java:32)
Caused by: java.lang.IllegalStateException: Failed to check the status of the service org.apache.dubbo.samples.api.GreetingService. No provider available for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 from the url nacos://localhost:8848/org.apache.dubbo.registry.RegistryService?application=nacos-registry-demo-consumer&dubbo=2.0.2&init=false&interface=org.apache.dubbo.samples.api.GreetingService&methods=sayHello&pid=19028®ister.ip=127.0.0.1&release=2.7.6-SNAPSHOT&revision=1.0.0&side=consumer&sticky=false&timeout=3000×tamp=1584584637337&version=1.0.0 to the consumer 127.0.0.1 use dubbo version 2.7.6-SNAPSHOT
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:349)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:258)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:158)
at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.getOrCreateProxy(ReferenceAnnotationBeanPostProcessor.java:274)
at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:143)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:359)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnnotationBeanPostProcessor.java:539)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:142)
... 12 more
备注
-
nacos中已存在 provider注册的服务 serviceName = "providers:org.apache.dubbo.samples.api.GreetingService:1.0.0:"
-
启动consumer时,NacosRegistry#doSubscribe(...)为了兼容会创建2个 serviceNames
- providers:org.apache.dubbo.samples.api.GreetingService:1.0.0:
- providers:org.apache.dubbo.samples.api.GreetingService:1.0.0
并且进行了 NacosRegistry#subscribeEventListener(...) 监听和订阅 nacos。
但是因为 provider 其实并不存在 providers:org.apache.dubbo.samples.api.GreetingService:1.0.0,
所以(nacos 回调的 instances = 0)NacosRegistry#notifySubscriber(URL , NotifyListener , Collection<Instance> )中会创建一个 empty 的 protocol。
又因为只有1个provider,所以RegistryDirectory#refreshInvoker()中满足了 forbidden 的条件,所以invokers被destroy....
Environment
Steps to reproduce this issue
测试代码:https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-nacos/dubbo-samples-nacos-registry
dubbo版本修改为"2.7.6.SNAPSHOT"
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
Actual Result
(IP地址手动改成了 127.0.0.1)
备注
nacos中已存在 provider注册的服务 serviceName = "providers:org.apache.dubbo.samples.api.GreetingService:1.0.0:"
启动consumer时,
NacosRegistry#doSubscribe(...)为了兼容会创建2个 serviceNames并且进行了
NacosRegistry#subscribeEventListener(...)监听和订阅 nacos。但是因为 provider 其实并不存在
providers:org.apache.dubbo.samples.api.GreetingService:1.0.0,所以(nacos 回调的 instances = 0)
NacosRegistry#notifySubscriber(URL , NotifyListener , Collection<Instance> )中会创建一个 empty 的 protocol。又因为只有1个provider,所以
RegistryDirectory#refreshInvoker()中满足了 forbidden 的条件,所以invokers被destroy....