一、背景
使用zookeeper操作时提示这个错误信息
ERROR org.apache.zookeeper.ClientCnxn:532 - Error while calling watcher
java.lang.NullPointerException
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:530)
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:505)
但是检查zookeeper服务器上实际的操作却是成功了。
二、抛出位置
zk = new ZooKeeper(url, 30000, null);
三、解决方法
zk = new ZooKeeper(url, 30000, new Watcher(){ @Override public void process(WatchedEvent event) { // TODO Auto-generated method stub logger.debug(" receive event : "+event.getType().name());
}
});