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

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

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 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配置如下:

<?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的社区也问题过类似问题,梁飞的回复可能是防火墙的问题,建议关掉试下。

 

你可能感兴趣的:(DUBBO)