http://www.reibang.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
問題復(fù)現(xiàn)
引入 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砰识,依賴的三方庫運(yùn)行時找不到方法,說明有jar包版本沖突佣渴。經(jīng)過排查辫狼,項(xiàng)目中引入的 dubbo 版本是 2.7.4.1 ,但是 brave-instrumentation-dubbo-rpc 依賴的 dubbo 版本是 2.6.x 版本的辛润。
但是項(xiàng)目中引入的 brave-instrumentation-dubbo-rpc
已經(jīng)是最新的膨处。通過下載 brave 源碼發(fā)現(xiàn)還有個 apache 的 dubbo brave-instrumentation-dubbo
,沒有 -rpc 的
砂竖,如下圖真椿。
最后將 maven 依賴修改為brave-instrumentation-dubbo
解決問題。
dubbo 2.6是alibaba的晦溪。從2.7開始捐獻(xiàn)給apache瀑粥。
解決后的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>