黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 Dubbo消費者找不到服務提供者問題

Dubbo消費者找不到服務提供者問題

更新時間:2021-09-07 11:05:04 來源:動力節點 瀏覽1892次

網上有很多類似問題,場景為Dubbo服務端通過監控中心查看是正常注冊了的,但是消費者卻執行時報錯,說找不到服務提供者。異常如下圖所示:

log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

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 com.unj.dubbotest.provider.DemoService. No provider available for the service com.unj.dubbotest.provider.DemoService from the url zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=consumer-of-helloworld-app&check=false&dubbo=2.5.3&interface=com.unj.dubbotest.provider.DemoService&loadbalance=roundrobin&methods=sayHello&pid=108320&side=consumer×tamp=1500875956242 to the consumer 192.168.0.101 use dubbo version 2.5.3

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)

at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)

at Consumer.main(Consumer.java:11)

Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.unj.dubbotest.provider.DemoService. No provider available for the service com.unj.dubbotest.provider.DemoService from the url zookeeper://localhost:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=consumer-of-helloworld-app&check=false&dubbo=2.5.3&interface=com.unj.dubbotest.provider.DemoService&loadbalance=roundrobin&methods=sayHello&pid=108320&side=consumer×tamp=1500875956242 to the consumer 192.168.0.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:168)

... 6 more

一般由于以下前3種原因,這邊是因為第4種,這里一一列舉出來:

1.防火墻問題:可以通過telnet嘗試連接服務端提供服務的地址加端口,看是否能夠正常連接。不行可能需要關閉防火墻,或配置開放端口(大神操作)

2.注冊使用的網段ip錯誤:一般是由于系統有多個ip,結果使用了一個與消費者不通的ip進行注冊,可以在監控中心查看注冊的url是什么ip,如下圖所示,這邊使用的192.168.0.101的內部ip,是通的。

如果的確是ip的問題,那么可以通過修改配置文件,在服務端的dubbo:protocol節點配置服務開放端口時,同時指定服務提供ip。這里消費者端好像也可以配置host,我覺得意義不大,這里沒有試過。

<?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"  /> 
    <!-- 使用multicast廣播注冊中心暴露服務地址 -->
    <!-- <dubbo:registry address="multicast://224.5.6.7:1234?unicast=false" />-->
    <!-- zookeeper服務注冊中心 -->
    <dubbo:registry address="zookeeper://localhost:2181"  check="true" />    
    <!-- 用dubbo協議在20880端口暴露服務 -->
    <dubbo:protocol name="dubbo" host="192.168.0.101" port="20882"  /> 
    <!-- 聲明需要暴露的服務接口 -->
    <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"  version="1.0"/> 
    <!-- 和本地bean一樣實現服務 -->
    <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl" />
</beans>

3.版本號問題如上圖所示,服務端在dubbo:service的節點下配置了版本1.0,那么客戶端也需要在對應的dubbo:reference節點下配置對應版本號,否則也是會報上面錯誤的。筆者最開始遇到的問題不是前面三種的任何一種,但是發現第4點的問題后發現還是不行,進而基于網上有的幾個原因進行排查,結果發現是之前按照網上說的配了下版本號,但是最終沒有保持一致。

<?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"  /> 
    <!-- 使用multicast廣播注冊中心暴露發現服務地址 -->
    <!-- <dubbo:registry address="multicast://224.5.6.7:1234?unicast=false" /> -->
    <dubbo:registry address="zookeeper://localhost:2181"/>
    <!-- <dubbo:protocol host="192.168.0.101" /> -->
    <!-- 生成遠程服務代理,可以和本地bean一樣使用demoService -->
    <dubbo:reference id="demoService"  interface="com.alibaba.dubbo.demo.DemoService"  version="1.0"/>
    <!-- add by liuming to avoid reference 3rd party components -->
</beans>

4.依賴組件沒有引用全。通過使用網上現有的demo,我發現居然可以,然后與我自己搭的環境進行對比。最終發現消費者這端我忘記添加netty依賴組件了~~。這里要注意的是,缺少netty組件依賴報錯和找不到服是一樣的,所以很難辨認原因,缺少其他組件可能也有此現象。這點就要進行仔細排查了。最后吐槽下,缺少netty組件不應該報類找不到異常嗎?這個估計是把異常catch重新拋了一個新異常,把真實原因隱藏了,感覺有些不易維護,這里用的2.5.3版本,不知道后面有沒有優化。

以上就是動力節點小編介紹的"Dubbo消費者找不到服務提供者問題",希望對大家有幫助,想了解更多可查看Dubbo教程。動力節點在線學習教程,針對沒有任何Java基礎的讀者學習,讓你從入門到精通,主要介紹了一些Java基礎的核心知識,讓同學們更好更方便的學習和了解Java編程,感興趣的同學可以關注一下。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 国产又湿又黄又硬又刺激 | 欧美性猛交xxx嘿人猛交 | 国产丶欧美丶日韩丶不卡影视 | 成人免费视频一区二区 | 天天做天天爽爽快快 | 99久久999久久久综合精品涩 | 国产成人啪精品视频免费网 | 国产丝袜精品丝袜久久 | 日本在线视频一区二区 | 一级片在线视频 | 亚洲视频久久 | 窝窝午夜影院 | 亚欧成人一区二区 | 一区二区不卡免费视频 | 99久久伊人 | 日日狠狠太爽爽 | 亚洲熟乱| 国产免费播放一区二区 | 日本老年人精品久久中文字幕 | 国产日韩欧美中文字幕 | 国产精品久久久久久久人人看 | 波多野结衣福利视频 | 欧美专区亚洲专区 | 欧美性xxx| 国产一级在线观看 | 最近2019中文字幕免费版视频 | 天天操操操操操操 | 好吊日在线观看 | 在线观看黄色网 | 尹人成人 | 成人满18在线观看网站免费 | 久草新免费 | 国产成人精品午夜在线播放 | 欧美人禽猛交狂配免费看 | 欧美一区二区视频高清转区 | 亚洲免费小视频 | 男女午夜免费视频 | 免费看国产一级片 | 午夜免费在线观看 | 日本日批视频 | 一级一级一级毛片免费毛片 |