Dubbo消费者启动报Failed to check the status of the service


博客分类: Dubbo
Dubbo
项目中准备使用Dubbo,运行官方的Provider和Consumer没有问题,自己写了个简单的SayHello进行测试,生产者启动后,通过DubboAdmin可以看到(不存在有人说的服务启动后又消失的问题),但启动生产者却报发下错误


Java代码  收藏代码
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service cn.feezu.carsearch.service.DemoService. No provider available for the service cn.feezu.carsearch.service.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=consumer-of-helloworld-app&default.timeout=5000&dubbo=2.5.3&interface=cn.feezu.carsearch.service.DemoService&methods=sayHello&pid=8148&side=consumer&timestamp=1440572169099 to the consumer 10.10.8.101 use dubbo version 2.5.3  
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:151)  
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)  
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1514)  
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:252)  
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)  
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973)  
    at Main.main(Main.java:15)  
Caused by: java.lang.IllegalStateException: Failed to check the status of the service cn.feezu.carsearch.service.DemoService. No provider available for the service cn.feezu.carsearch.service.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=consumer-of-helloworld-app&default.timeout=5000&dubbo=2.5.3&interface=cn.feezu.carsearch.service.DemoService&methods=sayHello&pid=8148&side=consumer&timestamp=1440572169099 to the consumer 10.10.8.101 use dubbo version 2.5.3  
    at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)  
    at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)  
    at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)  
    at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)  
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:144)  
    ... 6 more  
生产者的XML配置如下:


Xml代码  收藏代码
<?xml version="1.0" encoding="UTF-8" ?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
       http://www.springframework.org/schema/beans/spring-beans.xsd  
       http://code.alibabatech.com/schema/dubbo  
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd   
       ">  
    <dubbo:application name="hello-world-app" />  
   
    <!--zookeeper注册中心 -->  
    <dubbo:registry address="zookeeper://127.0.0.1:2181" />      
       
    <!--使用multicast广播注册中心暴露服务地址 -->  
    <!-- <dubbo:registry address="multicast://10.10.8.101:20881" /> -->  
    <dubbo:protocol name="dubbo" port="20881" />  
  
    <dubbo:service  
        interface="cn.feezu.carsearch.service.DemoService" ref="demoService" version="1.0"  />  
           
    <!-- 和本地bean一样实现服务 -->  
    <bean id="demoService"  
        class="cn.feezu.carsearch.serviceImpl.DemoServiceImpl" />  
</beans>  
 消费者的XML配置如下:


Java代码  收藏代码
<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans          
    http://www.springframework.org/schema/beans/spring-beans.xsd          
    http://code.alibabatech.com/schema/dubbo          
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">  
    
    <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->  
    <dubbo:application name="consumer-of-helloworld-app"  />  
    
    <!--zookeeper注册中心 -->  
    <dubbo:registry address="zookeeper://127.0.0.1:2181" />      
    
  <dubbo:consumer timeout="5000"/>    
    
    <!-- 生成远程服务代理,可以和本地bean一样使用demoService -->  
    <dubbo:reference id="demoService" interface="cn.feezu.carsearch.service.DemoService" />  
    
</beans>  
 


经过反复查找原因终于锁定了生产者XML文件中的version="1.0"


教训:如果生产者设定了服务的版本,消费者一定要提供相应的版本号(或空或写入对应的版本号)


 


如果有朋友不是这个问题,建议看看防火墙,有也在Dubbo的社区也问题过类似问题,梁飞的回复可能是防火墙的问题,建议关掉试下。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值