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.(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 依赖如下


    org.springframework.cloud
    spring-cloud-starter-sleuth


    io.zipkin.brave
    brave-instrumentation-dubbo-rpc


    org.springframework.cloud
    spring-cloud-starter-zipkin

抛出如下异常

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.(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.(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.(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

    org.springframework.cloud
    spring-cloud-starter-sleuth


    io.zipkin.brave
    brave-instrumentation-dubbo


    org.springframework.cloud
    spring-cloud-starter-zipkin

你可能感兴趣的:(spring cloud alibaba dubbo 链路跟踪报错问题解决 java.lang.NoSuchMethodError: 'void com.alibaba.dubbo.rpc.pr...)