分布式項目報錯及解決
dubbo分布式項目
1.在注冊中心找不到對應的服務
|
java.lang.IllegalStateException: Failed to check the status of the service com.pinyougou.sellergoods.service.BrandService. No provider available for the service com.pinyougou.sellergoods.service.BrandService from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=pinyougou-manager-web&dubbo=2.8.4&interface=com.pinyougou.sellergoods.service.BrandService&methods=update,get,delete,selectOptionList,add,getListByPage&pid=3980&revision=0.0.1-SNAPSHOT&side=consumer×tamp=1501146823396 to the consumer 172.16.17.14 use dubbo version 2.8.4 |
這種錯誤是服務層代碼沒有成功注冊到注冊中心導致,請檢查一下你的服務層代碼是否添加了@service注解,并且該注解的包一定是com.alibaba.dubbo.config.annotation包,不是org.springframework.stereotype.Service,這個地方極容易出錯。另外還有一個原因就是你的服務層工程由于某些原因沒有正常啟動,也無法注冊到注冊中心里。
2.無法連接到注冊中心
|
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 5000 org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:92) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:80) com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.<init>(ZkclientZookeeperClient.java:26) |
請檢查IP與端口是否填寫正確,檢查注冊中心是否正常啟動
3.dubbo標簽報錯
t
通常是dubbo.xsd文件有錯,重新添加后右鍵這個xml文件選擇validate,然后,windows-preferences-validation,把下面2個勾去掉即可

4.web工程缺少分頁依賴

5.報錯,類找不到

需要在web消費者工程加分頁及mybatis依賴
<!-- 分頁 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
</dependency>
6.報服務超時
com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout

解決:服務消費者設置超時
<dubbo:provider timeout="100000"/>
7.消費者調提供者能正常返回數據,但前端取值卻是空集合,返回對象沒有序列化和加set,get方法
8.無法請求FastDFS服務器,報如下異常,
java.net.SocketTimeoutException: connect timed out
java.lang.Exception: getStoreStorage fail, errno code: 0
解決方法即可
網絡適配器改為僅主機模式

9.
com.alibaba.dubbo.remoting.RemotingException: message can not send, because channel is closed . url:dubbo://192.168.0.113:20881/com.pinyougou.sellergoods.service.SellerService?anyhost=true&application=pinyougou-shop-web&check=false&codec=dubbo&default.timeout=100000&dubbo=2.8.4&generic=false&heartbeat=60000&interface=com.pinyougou.sellergoods.service.SellerService&methods=update,findOne,findAll,updateStatus,delete,findPage,add&pid=12128&revision=0.0.1-SNAPSHOT&side=consumer×tamp=1607993400111

本機ip發生了變更,修改本機Ip和dubbo-admin管理界面顯示一樣
10.java.lang.IllegalStateException: Failed to check the status of the service com.pinyougou.search.service.ItemSearchService. No provider available for the
報沒有提供者,service工程可能沒啟動或配置zookeeper服務器ip不正確
11.使用solr時,
org.springframework.data.solr.UncategorizedSolrException: Invalid content type: ; nested exception is org.apache.http.ParseException: Invalid content type:

經過排查是,項目名寫錯

12.Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
解決辦法:因為有別的tomcat在運行,任務管理器把javax結束即可
13.maven install 報錯,控制臺其實有2個項目不存在,原因可能是把這2個項目刪了,但在parent工程pom.xml還存在依賴,需要刪除

13.解決3 字節的 UTF-8 序列的字節 3 無效
在pom.xml加上
<build> <!-- 防止啟動報錯utf-8錯誤 --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
14,建子工程模塊報錯,Could not calculate build plan

解決方案,在該項目pom.xml加入以下依賴,然后在改項目工作空間,cmd進入控制臺,mvn install
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
最后maven update→選Force Update of Snapshots/Releases 即可

springCloud項目
1.建立Maven工程時出錯,Failure to transfer antlr:antlr:jar XXXXXXXX
解決方案:
a.刪除本地倉庫后綴.lastUpdated為擴展名的文件
b. 然后在工程上點擊右鍵,選擇maven →Update Project
2.SpringCloud,feign遠程調用時報錯:feign.FeignException: status 404 reading xxx
原因:服務名寫錯,一定要和提供者服務名一樣


浙公網安備 33010602011771號