curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <>
Subject Re: Mac, Java 1.8.0_05, PowerMock 1.6, Curator 2.7, Zookeeper 3.4.6, Kafka 0.8.2-beta, can't start embedded TestingServer for unit test
Date Thu, 11 Dec 2014 18:09:39 GMT
Are you sure you’re getting ZooKeeper 3.4.6? It appears to be an incompatible version of
the ZooKeeper client JAR.


On December 11, 2014 at 12:22:16 PM, John Boardman ( wrote:

I am trying to use curator's embedded Zookeeper TestingServer to do my tests. Here is the
simplest generic test class I could come up with that displays the error. Has anyone seen

package com;

import java.util.Properties;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServerStartable;
import kafka.utils.TestUtils;
import org.apache.curator.test.TestingServer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

public class TestMe {
    KafkaServerStartable kafkaServer;
    TestingServer zkServer;

    public TestMe() throws Exception {
        zkServer = new TestingServer();
        KafkaConfig config = getKafkaConfig(zkServer.getConnectString());
        kafkaServer = new KafkaServerStartable(config);

    private static KafkaConfig getKafkaConfig(final String zkConnectString) {
        scala.collection.Iterator<Properties> propsI = TestUtils.createBrokerConfigs(1,
        assert propsI.hasNext();
        Properties props =;
        assert props.containsKey("zookeeper.connect");
        props.put("zookeeper.connect", zkConnectString);
        return new KafkaConfig(props);

    public String getKafkaBrokerString() {
        return String.format("localhost:%d", kafkaServer.serverConfig().port());

    public String getZkConnectString() {
        return zkServer.getConnectString();

    public int getKafkaPort() {
        return kafkaServer.serverConfig().port();

    public void stop() throws IOException {

    public void test00() throws Exception {
The error I am getting is this:

10:29:50.374 [Thread-0] ERROR o.a.c.test.TestingZooKeeperServer - From testing server (random
state: false) for instance: InstanceSpec{dataDirectory=/var/folders/51/7vtgpj8938j5snr6f49l3qzh0000gn/T/1418315390050-0,
port=58985, electionPort=58986, quorumPort=58987, deleteDataDirectoryOnClose=true, serverId=1,
tickTime=-1, maxClientCnxns=-1} org.apache.curator.test.InstanceSpec@e669

java.lang.ClassCastException: class

at java.lang.Class.asSubclass( ~[na:1.8.0_05]

at$ ~[na:1.8.0_05]

at$ ~[na:1.8.0_05]

at Method) ~[na:1.8.0_05]

at ~[na:1.8.0_05]

at org.apache.zookeeper.server.ServerCnxnFactory.configureSaslLogin(

at org.apache.zookeeper.server.NIOServerCnxnFactory.configure(

at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(

at org.apache.curator.test.TestingZooKeeperMain.runFromConfig(

at org.apache.curator.test.TestingZooKeeperServer$ ~[na:2.7.0]
View raw message