首页  |  知识库  |  资源下载  |  在线工具  |  A-Z  •  JAR  •  名词查         

解决zookeeper调试报"org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for ...master"错误

标签:apache,ZooKeeper,KeeperException,ConnectionLossException,zookeeper-3.4.13.jar,3.4.6     发布时间:2019-04-06   

一、问题说明

通过zookeeper的Node节点集群管理与Master选举客户端代码示例连接zookeeper-3.4.6服务端,运行后报"Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /com/xwood/MasterElection/master"错误,详情日志>>

SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version@b@log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).@b@log4j:WARN Please initialize the log4j system properly.@b@Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /com/xwood/MasterElection/master@b@	at org.apache.zookeeper.KeeperException.create(KeeperException.java:102)@b@	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)@b@	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:792)@b@	at zookeeper.master.Node1.<init>(Node1.java:23)@b@	at zookeeper.master.Node1.main(Node1.java:57)

二、解决方法

因服务端安装是zookeeper-3.4.6版本,代码中依赖包使用的zookeeper-3.4.13.jar,造成版本不一致导致无法连接,改为安装软件中zookeeper-3.4.6.jar版本,问题即可解决了(完整示例项目&依赖包可以到资源下载页面进行获取)。