Apache Curator TestingServer creation throws java.lang.NoSuchMethodError

笑着哭i 提交于 2020-04-30 06:31:22

问题


I am trying to just run a TestingServer to be able to write unit tests for it.

    val zkServer = new TestingServer(2182)
    println(zkServer.getPort)

My pom has the following dependencies related to Curator, I have tried version 4.2.0 and 4.3.0, both throw the same error:

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-framework</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.apache.curator/curator-recipes -->
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-recipes</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-test</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>

The Error thrown is this:

Exception in thread "Thread-0" java.lang.NoSuchMethodError: org.apache.zookeeper.server.ZooKeeperServer.<init>(Lorg/apache/zookeeper/server/persistence/FileTxnSnapLog;IIILorg/apache/zookeeper/server/ZKDatabase;)V
at org.apache.curator.test.TestingZooKeeperMain$TestZooKeeperServer.<init>(TestingZooKeeperMain.java:265)
at org.apache.curator.test.TestingZooKeeperMain.internalRunFromConfig(TestingZooKeeperMain.java:226)
at org.apache.curator.test.TestingZooKeeperMain.runFromConfig(TestingZooKeeperMain.java:132)
at org.apache.curator.test.TestingZooKeeperServer$1.run(TestingZooKeeperServer.java:158)
at java.lang.Thread.run(Thread.java:748)

回答1:


I think Curator is only compatible with zookeeper 3.5.x right now. I was trying to run it with 3.6.0. Hence the problem switching to 3.5.x fixed the issue for me.



来源:https://stackoverflow.com/questions/61389209/apache-curator-testingserver-creation-throws-java-lang-nosuchmethoderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!