spring cloud alibaba dubbo 链路跟踪报错问题解决 java.lang.NoSuchMethodError: 'void com.alibaba.dubbo.rpc.pr...

https://www.jianshu.com/p/5cf443081430

spring cloud alibaba dubbo 链路跟踪(sleuth、zipkin、brave) 抛出如下异常解决方案。
java.lang.NoSuchMethodError: 'void com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter.<init>(com.alibaba.dubbo.remoting.exchange.ResponseFuture)'

  • spring boot 版本 2.2.5.RELEASE
  • spring cloud 版本 Hoxton.SR3
  • spring cloud alibaba 版本 2.2.0.RELEASE

问题复现

引入 sleuth、brave、zipkin 的 maven 依赖如下

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
    <groupId>io.zipkin.brave</groupId>
    <artifactId>brave-instrumentation-dubbo-rpc</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

抛出如下异常

2020-04-09 17:52:52.849 ERROR [spring-cloud-alibaba-dubbo-client,,,] 14340 --- [           main] .s.DubboMetadataServiceInvocationHandler : Failed to invoke the method getServiceRestMetadata in the service org.apache.dubbo.rpc.service.GenericService. Tried 3 times of the providers [172.16.20.162:20880] (1/1) from the registry localhost:9090 on the consumer 172.16.20.162 using the dubbo version 2.7.4.1. Last error is: 'void com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter.<init>(com.alibaba.dubbo.remoting.exchange.ResponseFuture)'

org.apache.dubbo.rpc.RpcException: Failed to invoke the method getServiceRestMetadata in the service org.apache.dubbo.rpc.service.GenericService. Tried 3 times of the providers [172.16.20.162:20880] (1/1) from the registry localhost:9090 on the consumer 172.16.20.162 using the dubbo version 2.7.4.1. Last error is: 'void com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter.<init>(com.alibaba.dubbo.remoting.exchange.ResponseFuture)'
    at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:113) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:248) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:78) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:55) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.common.bytecode.proxy0.$invoke(proxy0.java) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at com.alibaba.cloud.dubbo.service.DubboMetadataServiceInvocationHandler.invoke(DubboMetadataServiceInvocationHandler.java:48) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.sun.proxy.$Proxy150.getServiceRestMetadata(Unknown Source) ~[na:na]
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.getServiceRestMetadataSet(DubboServiceMetadataRepository.java:597) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initDubboRestServiceMetadataRepository(DubboServiceMetadataRepository.java:486) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initSubscribedDubboMetadataService(DubboServiceMetadataRepository.java:634) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.initializeMetadata(DubboServiceMetadataRepository.java:292) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.subscribeDubboServiceURL(AbstractSpringCloudRegistry.java:257) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.lambda$doSubscribeDubboServiceURLs$0(AbstractSpringCloudRegistry.java:206) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
    at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[na:na]
    at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.doSubscribeDubboServiceURLs(AbstractSpringCloudRegistry.java:206) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.subscribeDubboServiceURLs(AbstractSpringCloudRegistry.java:172) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at com.alibaba.cloud.dubbo.registry.AbstractSpringCloudRegistry.doSubscribe(AbstractSpringCloudRegistry.java:166) ~[spring-cloud-alibaba-dubbo-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.apache.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:295) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:172) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:412) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:393) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:71) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:69) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:128) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:396) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:329) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:250) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.getOrCreateProxy(ReferenceAnnotationBeanPostProcessor.java:246) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:143) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.getInjectedObject(AnnotationInjectedBeanPostProcessor.java:359) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement.inject(AnnotationInjectedBeanPostProcessor.java:539) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:146) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1427) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
    at com.test.dubbo.client.DubboSpringCloudClientBootstrap.main(DubboSpringCloudClientBootstrap.java:150) ~[classes/:na]
Caused by: java.lang.NoSuchMethodError: 'void com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter.<init>(com.alibaba.dubbo.remoting.exchange.ResponseFuture)'
    at brave.dubbo.rpc.TracingFilter.ensureSpanFinishes(TracingFilter.java:167) ~[brave-instrumentation-dubbo-rpc-5.10.1.jar:na]
    at brave.dubbo.rpc.TracingFilter.invoke(TracingFilter.java:126) ~[brave-instrumentation-dubbo-rpc-5.10.1.jar:na]
    at com.alibaba.dubbo.rpc.Filter.invoke(Filter.java:29) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.filter.GenericImplFilter.invoke(GenericImplFilter.java:119) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:92) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:60) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$CallbackRegistrationInvoker.invoke(ProtocolFilterWrapper.java:157) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82) ~[dubbo-2.7.4.1.jar:2.7.4.1]
    ... 51 common frames omitted

问题排查分析

NoSuchMethodError 是一个Error,依赖的三方库运行时找不到方法,说明有jar包版本冲突。经过排查,项目中引入的 dubbo 版本是 2.7.4.1 ,但是 brave-instrumentation-dubbo-rpc 依赖的 dubbo 版本是 2.6.x 版本的。
但是项目中引入的 brave-instrumentation-dubbo-rpc 已经是最新的。通过下载 brave 源码发现还有个 apache 的 dubbo brave-instrumentation-dubbo没有 -rpc 的,如下图。
最后将 maven 依赖修改为brave-instrumentation-dubbo解决问题。
dubbo 2.6是alibaba的。从2.7开始捐献给apache。

image.png

解决后的maven依赖如下

  • brave-instrumentation-dubbo
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
    <groupId>io.zipkin.brave</groupId>
    <artifactId>brave-instrumentation-dubbo</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,163评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,301评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,089评论 0 352
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,093评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,110评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,079评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,005评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,840评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,278评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,497评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,667评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,394评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,980评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,628评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,796评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,649评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,548评论 2 352

推荐阅读更多精彩内容