zkclient中包引用不对,导致NoSuchMethodError

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)
@btnguyen2k
 
Owner
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

posted @ 2018-01-09 11:11  zhucezmf  阅读(2268)  评论(0编辑  收藏  举报