起因:我的Dubbo服务起不来:我本地Zookeeper3.4.11,Curator4.1
Caused by: org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /dubbo/com.demo.common.service.DemoService
at org.apache.zookeeper.KeeperException.create(KeeperException.java:) ~[zookeeper-3.5.-beta.jar:3.5.-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
at org.apache.zookeeper.KeeperException.create(KeeperException.java:) ~[zookeeper-3.5.-beta.jar:3.5.-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:) ~[zookeeper-3.5.-beta.jar:3.5.-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
at org.apache.curator.framework.imps.CreateBuilderImpl$.call(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.framework.imps.CreateBuilderImpl$.call(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:) ~[curator-client-4.1..jar:na]
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:) ~[curator-client-4.1..jar:na]
at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:) ~[curator-framework-4.1..jar:4.1.]
at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:) ~[dubbo-2.6..jar:2.6.]
... common frames omitted
于是去了解这个版本对应关系如下:
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的吧,比如:
<!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.13</version>
<type>pom</type>
</dependency>
版本列表
同一个项目有三个版本也是醉了,貌似现在2.X和4.X是主打了,3.X被边缘了?