Dubbo报错:no provider available for the service

在整合dubbo开发项目时,web端启动控制台报错“no provider available for the service”,原因是Service接口创建失败,消费者访问提供者失败。Dubbo默认启动时检查依赖服务可用性,可通过check=\false\关闭检查,包括关闭某个服务、所有服务及注册中心的启动时检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在整合dubbo开发项目的时候,服务端能正常启动,启动web端的时候,控制台报错:no provider available for the service
这是个比较头疼的问题,控制台报错如下

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-25 11:37:47.560 ERROR 1208 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'doctorController': Injection of @org.apache.dubbo.config.annotation.Reference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV. No provider available for the service medicalcloud/com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV from the url zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?application=medicalcloud-consumer&default.timeout=20000&dubbo=2.0.2&group=medicalcloud&interface=com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV&methods=getDoctorByCondition,getDoctorDetail&pid=1208&qos.enable=false&register.ip=192.168.0.103&release=2.7.0&side=consumer&timestamp=1558755467501 to the consumer 192.168.0.103 use dubbo version 2.7.0
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:132)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1416)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at com.quliankeji.medicalcloud.portal.PortalApplication.main(PortalApplication.java:16)
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV. No provider available for the service medicalcloud/com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV from the url zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?application=medicalcloud-consumer&default.timeout=20000&dubbo=2.0.2&group=medicalcloud&interface=com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV&methods=getDoctorByCondition,getDoctorDetail&pid=1208&qos.enable=false&register.ip=192.168.0.103&release=2.7.0&side=consumer&timestamp=1558755467501 to the consumer 192.168.0.103 use dubbo version 2.7.0
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:393)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:301)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:225)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.init(ReferenceAnnotationBeanPostProcessor.java:162)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.access$100(ReferenceAnnotationBeanPostProcessor.java:146)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildInvocationHandler(ReferenceAnnotationBeanPostProcessor.java:140)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildProxy(ReferenceAnnotationBeanPostProcessor.java:122)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:116)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:49)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.getInjectedObject(AnnotationInjectedBeanPostProcessor.java:340)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement.inject(AnnotationInjectedBeanPostProcessor.java:520)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:128)
	... 17 common frames omitted


选择重要的信息进行观察,Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV,这里的意思就是这个Service接口创建失败,
后面的异常信息非常重要:No provider available for the service ,意思就是对于service来说,没有可实现的provider
消费者在访问提供者的时候失败了。

解决方案

Dubbo默认(缺省)会在启动时检查依赖的服务是否可用,不可用时会抛出异常,阻止Spring初始化完成,以便上线时,能及早发现问题,默认check=true
如果你的Spring容器是懒加载的,或者通过API编程延迟引用服务,请关闭check,否则服务临时不可用时,会抛出异常,拿到null引用,如果check=false,总是会返回引用,当服务恢复时,能自动连上。
可以通过check=”false”关闭检查,比如,测试时,有些服务不关心,或者出现了循环依赖,必须有一方先启动。

  1. 关闭某个服务的启动时检查
<dubbo:reference interface="com.taotao.ItemService" check="false" />
  1. 关闭所有服务的启动时检查,
<dubbo:consumer check="false" />
  1. 关闭注册中心启动时检查:(注册订阅失败时报错)
<dubbo:registry check="false" />
### 关于 Dubbo 框架错误码 99-0 的分析 Dubbo 是一个高性能的 Java 分布式服务框架,广泛应用于微服务架构中。然而,在实际使用过程中可能会遇到各种异常情况,其中 `error code 99-0` 是一种常见的运行时错误。 #### 错误描述 根据已知的信息以及社区反馈,`error code 99-0` 通常表示客户端发送了一个请求到服务器端,但由于某些原因未能成功处理该请求并返回结果。具体表现为: 1. **超时问题**:如果消费者等待提供者响应的时间超过了配置的最大超时时间,则会触发此错误[^1]。 2. **网络连接中断**:当网络不稳定或者突然断开时也可能引发此类错误[^2]。 3. **序列化/反序列化失败**:在传输对象的过程中发生编码或解码错误也会导致类似的错误提示[^3]。 #### 解决方案 针对以上可能的原因可以采取以下措施来排查和解决问题: ##### 配置合理的超时设置 确保 ConsumerProvider 双方都设置了恰当的服务调用超时时长参数(如 timeout),并且这个值应该基于业务需求合理调整而不是简单地增大它直到不再抛出异常为止;同时还需要注意的是不同版本之间可能存在默认行为差异所以最好显式指定这些属性以免意外情况发生[^1]。 ```properties dubbo.consumer.timeout=5000 # 单位毫秒,默认为一分钟即60*1000ms ``` ##### 加强网络稳定性保障机制 通过引入心跳检测功能定期验证链路状态从而及时发现潜在隐患并作出相应补偿动作比如重新建立链接等操作以减少因短暂失联造成的负面影响[^2]。 另外还可以考虑部署高可用集群模式进一步提升系统的健壮性和容灾能力防止单点故障影响整体性能表现。 ##### 处理好自定义POJO类中的字段类型兼容性问题 由于双方使用的JDK版本或者其他依赖库存在细微差别可能导致即使表面上看起来相同的Java Bean实际上并不完全一致进而引起无法正常完成消息转换过程的情况因此建议开发者仔细核对自己项目里涉及到远程通信的所有实体结构确保它们能够在任意环境下都能被正确解析出来而不会因为缺少某个getter/setter方法或者是父类继承关系改变等因素干扰正常的流程执行路径[^3]. 最后提醒一点就是每当修改了任何一方的相关定义之后都需要同步更新另一侧对应的实现部分这样才能保持一致性避免不必要的麻烦出现. --- ### 示例代码片段展示如何捕获并记录特定类型的异常以便后续诊断分析工作开展更加顺利高效: ```java try { // 正常业务逻辑调用... } catch (RemotingException e) { if ("99-0".equals(e.getCode())) { log.error("Detected ErrorCode 99-0 during invocation.", e); // 自定义重试策略或其他补救措施... } } ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值