zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for {root.path}

1 异常结果

org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /curator

	at org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1189)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1166)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1163)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:603)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:593)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:47)
	at cn.practice.zk.ZookeeperClientPractice.test(ZookeeperClientPractice.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

  

2 原因是Zookeeper的版本与curator的版本不匹配造成的

自己查阅了一下资料发现匹配规则如下

curator作为zookeeper的客户端,并不是最新版的就没问题,因为它的版本和zookeeper的版本有对应关系。

ZooKeeper 3.5.x
Curator4.0十分依赖Zookeeper3.5.X

ZooKeeper 3.4.x
Curator4.0在软兼容模式下支持Zookeeper3.4.X,但是需要依赖排除zookeeper

复制代码
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>${curator-version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </exclusion>
    </exclusions>
</dependency>
复制代码
同时必须加入Zookeeper3.4.X的依赖,并且呢,因为是软兼容模式,一些3.4.X不具备的新特性是不能使用的。

低版本
对于Curator2.X是支持Zookeeper3.4.X的,所以如果目前你是Zookeeper3.4.X的版本,还是使用Curator2.X的吧,

  

3 解决方案,因为我的部署Zookeeper版本为3.4.5所以应该选择2.x的curator版本

 

 <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-client</artifactId>
            <version>2.12.0</version>

        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>2.12.0</version>
        </dependency>

  重新maven导入一下jar包解决问题,之前已经创建成功过了,所以抛出节点已经存在的错误

 

 

转载于:https://www.cnblogs.com/QuestionsZhang/p/10411668.html

org.apache.zookeeper.KeeperException$ConnectionLossExceptionZooKeeper客户端库中的一个异常类,表示与ZooKeeper服务器的连接丢失。这个异常通常在以下情况下抛出: 1. 当客户端与ZooKeeper服务器的连接意外断开时,会抛出ConnectionLossException异常。 2. 当客户端尝试与ZooKeeper服务器建立连接时,如果连接失败,也会抛出ConnectionLossException异常。 这个异常类的完整名称是org.apache.zookeeper.KeeperException$ConnectionLossException,它是KeeperException的一个子类。KeeperExceptionZooKeeper客户端库中的一个通用异常类,用于表示与ZooKeeper服务器交互过程中的各种错误。 在处理ConnectionLossException异常时,可以采取以下措施: 1. 检查网络连接:首先,确保客户端与ZooKeeper服务器之间的网络连接是正常的。可以尝试ping ZooKeeper服务器的IP地址,以确保网络连接没有问题。 2. 重试操作:如果连接丢失是由于网络问题导致的,可以尝试重新连接并重试之前的操作。可以使用重试机制来处理ConnectionLossException异常,例如使用循环和延迟重试策略。 3. 检查ZooKeeper服务器状态:如果连接丢失是由于ZooKeeper服务器本身的问题导致的,可以检查ZooKeeper服务器的状态。可以查看ZooKeeper服务器的日志文件,以了解是否有任何错误或异常发生。 4. 调整ZooKeeper客户端配置:有时,连接丢失问题可能是由于ZooKeeper客户端配置不正确导致的。可以检查ZooKeeper客户端的配置文件,确保配置正确。 总之,org.apache.zookeeper.KeeperException$ConnectionLossException表示与ZooKeeper服务器的连接丢失,可以通过检查网络连接、重试操作、检查ZooKeeper服务器状态和调整ZooKeeper客户端配置来处理这个异常。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值