zkclient中包引用不对,导致NoSuchMethodError
nidonglin commented on 31 Oct 2014
|
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.(Ljava/lang/String;ILorg/apache/zookeeper/Watcher;Z)V
at org.apache.curator.utils.DefaultZookeeperFactory.newZooKeeper(DefaultZookeeperFactory.java:29)
at org.apache.curator.framework.imps.CuratorFrameworkImpl$2.newZooKeeper(CuratorFrameworkImpl.java:169)
at org.apache.curator.HandleHolder$1.getZooKeeper(HandleHolder.java:94)
at org.apache.curator.HandleHolder.getZooKeeper(HandleHolder.java:55)
at org.apache.curator.ConnectionState.reset(ConnectionState.java:219)
at org.apache.curator.ConnectionState.start(ConnectionState.java:103)
at org.apache.curator.CuratorZookeeperClient.start(CuratorZookeeperClient.java:188)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.start(CuratorFrameworkImpl.java:234)
at com.github.ddth.zookeeper.ZooKeeperClient._connect(ZooKeeperClient.java:534)
at com.github.ddth.zookeeper.ZooKeeperClient.init(ZooKeeperClient.java:656)
at com.github.ddth.kafka.KafkaClient.init(KafkaClient.java:117)
at org.apache.myfaces.blank.ConsumerDemo5.main(ConsumerDemo5.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
|
Owner
btnguyen2k commented on 31 Oct 2014
|
Hi nidonglin, for some reasons maven pull an old version of Apache Zookeeper which does not have this method. I'm checking on this issue.
A workaround for now is to add Apache Zookeeper 3.4.6+ explicitly to your project.
|
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
默认会引入zookeeper3.3.3.jar,但curator2.7.0会默认依赖zookeeper3.6.jar

浙公网安备 33010602011771号