错误日志:
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException:
KeeperErrorCode = ConnectionLoss for /test
at org.apache.zookeeper.KeeperException.create(KeeperException.java:102)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1549)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1183)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1160)
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:1157)
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:607)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:597)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
at zookeeper4.Test.createNode(Test.java:154)
at zookeeper4.Test.main(Test.java:57)
maven构建的测试工程,先使用了zk原生包可以运行,后来加进了curator包,因为有其他的事参合,也不知道从什么时候开始测试代码就运行报错了。
网上查了各种问题,说什么linux防火墙没开、zk服务没有启动、client连接没成功就操作数据的,逐个检查都不是我的解决办法。
后来想起了引入了jar包,于是坚持maven配置
看到木有,有两个zk的jar包!!!!!!
于是去掉了其中一个原生jar包,再次运行main方法,测试成功!!