【总结】解决dubbo 升级至apache 2.7.18版本发生Zookeeper连接失败问题

问题描述

最近在做系统的架构升级,升级应用dubbo版本号至apache 2.7.18版,发生Caused by: java.lang.IllegalStateException: Failed to connect with zookeeper, pls check if url zookeeper://192.168.11.13:2149/ConfigCenterConfig?check=true&config-file=dubbo.properties&group=dubbo&highest-priority=false&timeout=3000 is correct.
错误。但这里奇怪的是,其他应用是没问题的。于是乎,将问题锁定在jar 包冲突上。

以下是详细错误信息。

错误信息

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxUserServiceImpl': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to connect with zookeeper, pls check if url zookeeper://192.168.11.13:2181/ConfigCenterConfig?check=true&config-file=dubbo.properties&group=dubbo&highest-priority=false&timeout=3000 is correct.
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:183)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1430)
	at 
……	org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318)
	... 49 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to connect with zookeeper, pls check if url zookeeper://192.168.11.13:2149/ConfigCenterConfig?check=true&config-file=dubbo.properties&group=dubbo&highest-priority=false&timeout=3000 is correct.
	at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration.(ZookeeperDynamicConfiguration.java:69)
	at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfigurationFactory.createDynamicConfiguration(ZookeeperDynamicConfigurationFactory.java:43)
	at 
……
com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:179)
	... 65 common frames omitted
2023-03-27 18:59:41,758  INFO   3018 --- [           main] [org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener:63] : [0] 

 :: Dubbo Spring Boot (v2.7.18) : https://github.com/apache/dubbo-spring-boot-project
 :: Dubbo (v2.7.18) : https://github.com/apache/dubbo
 :: Discuss group : [email protected]

排查解决

1)打包启动正常的应用,解压打包后的springboot jar。查看其BOOT-INF目录下的lib。将依赖的lib 列表,复制其名称,写入good-libs.txt文件。
【总结】解决dubbo 升级至apache 2.7.18版本发生Zookeeper连接失败问题_第1张图片
2)同样的方法,打包启动失败的应用,查看其springboot 最终 lib 依赖包列表,复制其名称,写入bad-libs.txt文件。

3)比对bad-lib.txt 、good-lib.txt,寻找两个包依赖不同之处,重点关注dubbo、zookeeper、curator相关的包。

果然,经过一番对比,发现是curator-client 版本不一致。
【总结】解决dubbo 升级至apache 2.7.18版本发生Zookeeper连接失败问题_第2张图片
4)查证 curator-client maven 依赖仲裁。
【总结】解决dubbo 升级至apache 2.7.18版本发生Zookeeper连接失败问题_第3张图片
原因是maven 发生依赖冲突时,最终采用了最短路径(路径只有2级,其他的版本都是3级路径),选择最底下的2.7.1版本。

现在只需要让2.10.0的版本被采纳就行了。

解决方法

1)方法一:直接声明curator-client坐标,让其优先级最高

       
            org.apache.curator
            curator-recipes
            2.10.0
        
        
            org.apache.curator
            curator-client
            2.10.0
        

2)方法二:排除 curator-client 2.7.1 的依赖。在引入2.7.1版本的地方,exclusion掉依赖即可。

				
                    curator-client
                    org.apache.curator
                

你可能感兴趣的:(dubbo,zookeeper,curator冲突,连接失败,pls,check)