no provider available for the service错误解决方案

举报
SHQ5785 发表于 2022/06/09 08:58:01 2022/06/09
【摘要】 在分布式项目中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&timestamp=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&timestamp=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&timestamp=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&timestamp=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&timestamp=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

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。