no provider available for the service错误解决方案
【摘要】 在分布式项目中Dubbo发布服务报No provider available for the service错误。错误信息如下:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubboServiceTest': FactoryBean thr...
在分布式项目中Dubbo
发布服务报No provider available for the service
错误。错误信息如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubboServiceTest': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest. No provider available for the service com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest from the url zookeeper://22.189.25.95:2181/com.alibaba.dubbo.registry.RegistryService?application=access-provider-ccms-test&dubbo=2.8.4&interface=com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest&methods=getResponseData&pid=8184&side=consumer×tamp=1523930029357 to the consumer 22.189.25.95 use dubbo version 2.8.4
[2018-04-17 10:57:23.488] [thread-main] [INFO] -- [DUBBO] Notify urls for subscribe url consumer://22.189.25.95/com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest?application=access-provider-ccms-test&category=providers,configurators,routers&check=false&dubbo=2.8.4&interface=com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest&methods=getResponseData&pid=11908&side=consumer×tamp=1523933842862, urls: [empty://22.189.25.95/com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest?application=access-provider-ccms-test&category=providers&check=false&dubbo=2.8.4&interface=com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest&methods=getResponseData&pid=11908&side=consumer×tamp=1523933842862, empty://22.189.25.95/com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest?application=access-provider-ccms-test&category=configurators&check=false&dubbo=2.8.4&interface=com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest&methods=getResponseData&pid=11908&side=consumer×tamp=1523933842862, empty://22.189.25.95/com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest?application=access-provider-ccms-test&category=routers&check=false&dubbo=2.8.4&interface=com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest&methods=getResponseData&pid=11908&side=consumer×tamp=1523933842862], dubbo version: 2.8.4, current host: 22.189.25.95com.alibaba.dubbo.rpc.RpcException: Forbid consumer 22.189.25.95 access service com.bocsoft.ccms.demo.dubbo.service.IDubboServiceTest from registry 22.189.25.95:2181 use dubbo version 2.8.4, Please check registry access list (whitelist/blacklist).
解决方案
Dubbo
默认(缺省)会在启动时检查依赖的服务是否可用,不可用时会抛出异常,阻止Spring
初始化完成,以便上线时,能及早发现问题,默认check=true
。
如果你的Spring
容器是懒加载的,或者通过API
编程延迟引用服务,请关闭check
,否则服务临时不可用时,会抛出异常,拿到null
引用,如果check=false
,总是会返回引用,当服务恢复时,能自动连上。
可以通过check=”false”
关闭检查,比如,测试时,有些服务不关心,或者出现了循环依赖,必须有一方先启动。
- 关闭某个服务的启动时检查:(没有提供者时报错)
<dubbo:reference interface="com.taotao.ItemService" check="false" />
- 关闭所有服务的启动时检查:(没有提供者时报错) 写在定义服务消费者一方
<dubbo:consumer check="false" />
- 关闭注册中心启动时检查:(注册订阅失败时报错)
<dubbo:registry check="false" />
附
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)