1. 程式人生 > >dubbo2.5.3消費dubbox提供的服務報錯

dubbo2.5.3消費dubbox提供的服務報錯

dubbox和dubbo 2.x是相容的,沒有改變dubbo的任何已有的功能和配置方式(除了升級了spring之類的版本),但是實際上確實不能相互相容相互呼叫服務。

其實不相容的原因是因為服務端受理請求時,在DecodeableRpcInvocation這個類出現異常,異常出線的行數106行 :


出現異常的原因報文解析decode異常。這個要了解dubbo協議的報文格式。
in 物件執行read操作,會一個一個偏移讀取報文dubbox提供的服務,當執行該行時,認為報文應該是一個整數,但是確是一個String,解析異常。 所以嘗試對DecodeableRpcInvocation類進行了相容處理:


修改的類如下所示:

/*
 * Copyright 1999-2011 Alibaba Group.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.alibaba.dubbo.rpc.protocol.dubbo;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
import com.alibaba.dubbo.common.serialize.Cleanable;
import com.alibaba.dubbo.common.serialize.ObjectInput;
import com.alibaba.dubbo.common.serialize.OptimizedSerialization;
import com.alibaba.dubbo.common.serialize.support.kryo.KryoSerialization;
import com.alibaba.dubbo.common.utils.Assert;
import com.alibaba.dubbo.common.utils.ReflectUtils;
import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.dubbo.remoting.Channel;
import com.alibaba.dubbo.remoting.Codec;
import com.alibaba.dubbo.remoting.Decodeable;
import com.alibaba.dubbo.remoting.exchange.Request;
import com.alibaba.dubbo.remoting.transport.CodecSupport;
import com.alibaba.dubbo.rpc.RpcInvocation;

import static com.alibaba.dubbo.rpc.protocol.dubbo.CallbackServiceCodec.decodeInvocationArgument;

/**
 * @author <a href="mailto:
[email protected]
">kimi</a> */ public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Decodeable { private static final Logger log = LoggerFactory.getLogger(DecodeableRpcInvocation.class); private Channel channel; private byte serializationType; private InputStream inputStream; private Request request; private volatile boolean hasDecoded; public DecodeableRpcInvocation(Channel channel, Request request, InputStream is, byte id) { Assert.notNull(channel, "channel == null"); Assert.notNull(request, "request == null"); Assert.notNull(is, "inputStream == null"); this.channel = channel; this.request = request; this.inputStream = is; this.serializationType = id; } public void decode() throws Exception { if (!hasDecoded && channel != null && inputStream != null) { try { decode(channel, inputStream); } catch (Throwable e) { if (log.isWarnEnabled()) { log.warn("Decode rpc invocation failed: " + e.getMessage(), e); } request.setBroken(true); request.setData(e); } finally { hasDecoded = true; } } } public void encode(Channel channel, OutputStream output, Object message) throws IOException { throw new UnsupportedOperationException(); } public Object decode(Channel channel, InputStream input) throws IOException { ObjectInput in = CodecSupport.getSerialization(channel.getUrl(), serializationType) .deserialize(channel.getUrl(), input); try { setAttachment(Constants.DUBBO_VERSION_KEY, in.readUTF()); setAttachment(Constants.PATH_KEY, in.readUTF()); setAttachment(Constants.VERSION_KEY, in.readUTF()); setMethodName(in.readUTF()); try { Object[] args; Class<?>[] pts; // NOTICE modified by lishen // 相容dubbo2.X begin. String dubboVerson=getAttachment(Constants.DUBBO_VERSION_KEY); if ("2.5.4".equals(dubboVerson) || "2.5.3".equals(dubboVerson)) { String desc=in.readUTF(); if (desc.length() == 0) { pts=DubboCodec.EMPTY_CLASS_ARRAY; args=DubboCodec.EMPTY_OBJECT_ARRAY; } else { pts=ReflectUtils.desc2classArray(desc); args=new Object[pts.length]; for (int i=0; i < args.length; i++) { try { args[i]=in.readObject(pts[i]); } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Decode argument failed: " + e.getMessage(), e); } } } } } // 相容dubbo2.X end. else { int argNum=in.readInt(); if (argNum >= 0) { if (argNum == 0) { pts=DubboCodec.EMPTY_CLASS_ARRAY; args=DubboCodec.EMPTY_OBJECT_ARRAY; } else { args=new Object[argNum]; pts=new Class[argNum]; for (int i=0; i < args.length; i++) { try { args[i]=in.readObject(); pts[i]=args[i].getClass(); } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Decode argument failed: " + e.getMessage(), e); } } } } } else { String desc=in.readUTF(); if (desc.length() == 0) { pts=DubboCodec.EMPTY_CLASS_ARRAY; args=DubboCodec.EMPTY_OBJECT_ARRAY; } else { pts=ReflectUtils.desc2classArray(desc); args=new Object[pts.length]; for (int i=0; i < args.length; i++) { try { args[i]=in.readObject(pts[i]); } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Decode argument failed: " + e.getMessage(), e); } } } } } } setParameterTypes(pts); Map<String, String> map=(Map<String, String>) in.readObject(Map.class); if (map != null && map.size() > 0) { Map<String, String> attachment=getAttachments(); if (attachment == null) { attachment=new HashMap<String, String>(); } attachment.putAll(map); setAttachments(attachment); } //decode argument ,may be callback for (int i=0; i < args.length; i++) { args[i]=decodeInvocationArgument(channel, this, pts, i, args[i]); } setArguments(args); } catch (ClassNotFoundException e) { throw new IOException(StringUtils.toString("Read invocation data failed.", e)); } } finally { // modified by lishen if (in instanceof Cleanable) { ((Cleanable) in).cleanup(); } } return this; } }
修改完這塊程式碼打成jar包重新定義dubbo版本為3.8.4,這樣的方式可以解決的問題是2,5.3可以消費3.8.4的服務,但是3.8.4不能消費2.5.3的服務,所以作為服務的提供方,應該升到3.8.4,如果僅僅是消費服務而不提供服務,可以用低版本的dubbo

相關推薦

dubbo2.5.3消費dubbox提供服務

dubbox和dubbo 2.x是相容的,沒有改變dubbo的任何已有的功能和配置方式(除了升級了spring之類的版本),但是實際上確實不能相互相容相互呼叫服務。 其實不相容的原因是因為服務端受理請求時,在DecodeableRpcInvocation這個類出現異常,異常

dubbo2.5.3升級到dobbo2.8.4(dubbox) jar

升級 nal 添加 end pri 3.1 ons work jar包 需要註意的地方: 1、pom文件中 dubbo的版本由2.5.3變為2.8.4,maven依賴如下: <dependency> <groupId>com

dubbo2.5.3升級到dobbo2.8.4(dubbox)遇到的問題

    <dependency>         <groupId>com.alibaba</groupId>         <artifactId>dubbo</artifactId>         <version>2.8.4&

2.Dubbo2.5.3註冊中心和監控中心部署

png pac org .gz nbsp ng- jps 路徑 -a 轉載請出自出處:http://www.cnblogs.com/hd3013779515/ 1.註冊中心Zookeeper安裝 (1)搭建要求 zk服務器集群規模不小於3個節點要求各服務器之間系統時間要保持

"net start mysql"啟動MySQL服務,提示發生系統錯誤5解決方法

在dos下執行”net start mysql”不能啟動MySQL服務! 提示發生系統錯誤 5;拒絕訪問!切換到管理員模式就可以啟動了。 一、錯誤截圖: 二、單次解決辦法 1、去”C:\Windows\System32”目錄找到”cmd.exe”: 2、右擊

Tomcat啟動服務:Unknown version string [3.1]. Default version will be used.

Tomcat、jdk、web.xml 對應關係: (版本往下相容) web.xml——version2.2——JDK1.1——Tomcat3.3 web.xml——version2.3——JDK1.3——Tomcat4.1 web.xml——version2.4——JDK1.4——T

Oracle11g啟動Server服務:錯誤1053:服務沒有及時響應或控制請求

今天 oracle11 alt .com 控制 啟動 oracl 電腦 變量 今日在啟動Oracle11g的服務時,突然莫名報錯,昨日尚一切正常,靜心細思:系統未升級;未安裝其他程序;未更改系統相關配置包括環境變量。 錯誤原因如下圖所示: 經過一番折騰,唯一發現今天特殊點

IIS運行WCF服務

imageview wcf not found 分享 圖片 -i 分享圖片 技術分享 inf 試圖加載格式不正確的程序 image 解決方法 image HTTP 錯誤 500.19 image 解決方法在控

啟動mysql服務:本地計算機上的mysql服務器啟動後停止,某些服務在....

結束進程 art 分享 start 技術分享 服務 AR all com 報錯如圖: 解決方法:1。初始化data文件(mysql安裝bin目錄下):mysql --initailize,需要等半分鐘左右才會有反應 2.如果提示有錯誤data目錄已經有了,有兩種方式,一種

Android Studio 3.0.1模擬器啟動Emulator: glClear:466 GL err 0x502

and RR 正常 分享圖片 oid src 圖片 下載 顯示 啟動模擬器時,報了一大堆以上錯誤 啟動起來之後, Emulator的畫面沒有正常顯示, 點擊鼠標會閃爍, 有時還會上下顛倒 有可能是驅動版本太低不支持一些特性,因此就下載個驅動精靈。升級了顯卡驅動,結果就能正

阿裏雲短信服務org.json.JSONArray.iterator()Ljava/util/Iterator

ray common code error: send group erb regions 最新版本 maven依賴如下: <!-- 阿裏雲短信sdk --> <dependency> <

CentOS7.5安裝WPS並解決字型

CentOS7為桌面系統 [[email protected] 下載]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 第一步、下載 下載連結: http://kdl.cc.kso

5.7 mysql命令gruop by this is incompatible with sql_mode=only_full_group_by

轉自:https://www.cnblogs.com/jim2016/p/6322703.html 在mysql 工具 搜尋或者插入資料時報下面錯誤: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY

mysql 5.7匯入較大檔案

Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline. 匯入s

記一次Zabbix 從 3.0 升級到 3.4,,遇到資料庫問題

記錄一次升級zabbix,資料庫報錯問題。以下是報錯內容 The frontend does not match Zabbix database. Current database version (mandatory/optional): 3020000/3020000. Require

APPCAN的mas服務

報錯資訊 主要是: [meap_im_java]load java warning { [Error: Cannot find module 'java'] code: 'MODULE_NOT_FOUND' } 原因 重新安裝了系統之後,APPCAN的預設的node的路徑改變了,添加回來

CentOS 7下啟動postfix服務:fatal: parameter inet_interfaces: no local interface found for ::1

pre code found control inter display interface ces tro sed -i ‘s/inet_interfaces = localhost/inet_interfaces = all‘ /etc/postfix/main.c

Redis關閉服務---(error) ERR Errors trying to SHUTDOWN. Check logs.

在關閉redis時遇到如下提示 127.0.0.1:6379> shutdown (error) ERR Errors trying to SHUTDOWN. Check logs. 百度後找到以下解決方案 1.在redis.conf中修改日誌檔案的位置 #日誌檔案位置 log

NGINX重啟服務問題

剛裝好NGINX服務,啟動時報錯[[email protected] nginx]# sbin/nginx -s reloadnginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"解決方法:啟動時需指定配置檔

5.04-springboot連線資料庫啟動

   部分異常資訊如下: 2018-12-05 17:00:19.810 ERROR 10908 --- [eate-1708786164] com.alibaba.druid.pool.DruidDataSource : create connection SQLExceptio