curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Keylis <vkeylis2...@gmail.com>
Subject Re: ClassCastException when starting test server
Date Wed, 19 Mar 2014 19:48:22 GMT
Any suggestion is appreciated

Sent from my iPhone

> On Mar 18, 2014, at 1:27 PM, Vadim Keylis <vkeylis2009@gmail.com> wrote:
> 
> I am using eclipse. Here is the simple java code 
> 
> package com.tagged.kafka.topic;
> 
> import static org.junit.Assert.*;
> 
> import gnu.trove.list.array.TIntArrayList;
> 
> import java.io.File;
> import java.util.Properties;
> import java.util.concurrent.ArrayBlockingQueue;
> import java.util.concurrent.CountDownLatch;
> import java.util.concurrent.atomic.AtomicBoolean;
> 
> import kafka.server.KafkaConfig;
> import kafka.server.KafkaServerStartable;
> 
> import org.I0Itec.zkclient.ZkClient;
> import org.apache.curator.test.TestingServer;
> import org.json.JSONException;
> import org.junit.After;
> import org.junit.Before;
> import org.junit.Test;
> import org.springframework.context.support.ClassPathXmlApplicationContext;
> 
> import com.tagged.kafka.FetchedMessageData;
> import com.tagged.kafka.topic.partition.PartitionControler;
> import com.tagged.kafka.topic.partition.PartitionOffsetResponse;
> import com.tagged.nib.Config;
> import com.tagged.nib.NibClient;
> import com.tagged.nib.util.zookeeper.ZkStringSerializer;
> import com.tagged.nib.util.zookeeper.ZkUtil;
> 
> public class TestTopicStream {
>     private String propertyFile;
>     private ClassPathXmlApplicationContext context;
>     private TestingServer zkServer;
>     KafkaServerStartable kafkaServer;
> 
>     @Before
>     public void setUp() throws Exception {
>         File currentPathResource = new File(".");
>         propertyFile = String.format("%s%starget%stest-classes%snib.test.properties",
 currentPathResource.getAbsoluteFile(),
>                                                                                     
 File.separator, 
>                                                                                     
 File.separator,
>                                                                                     
 File.separator);
>         context =
>          new ClassPathXmlApplicationContext(new String[] {"testConsumer.xml"});
>         zkServer = new TestingServer(2181);
>     }
> 
>     @After
>     public void tearDown() throws Exception {
>     }
> 
>     
>     @Test
>     public void dummyTest(){
>         
>     }
> }
> =================================================================== Pom file ======================================
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.tagged.client</groupId>
>   <artifactId>nib</artifactId>
>   <version>2.0</version>
>   <name>Simple NIB Client To subscribe to kafka</name>
>   <packaging>jar</packaging>
>   <parent>
>       <groupId>com.tagged</groupId>
>       <artifactId>mvnrpm</artifactId>
>       <version>1.0</version>
>   </parent>
>   <distributionManagement>
>     <repository>
>        <id>subversion-releases</id>
>        <name>subversion-releases</name>
>        <url>http://artifactory.tagged.com:8081/artifactory/libs-release-local</url>
>     </repository>
>   </distributionManagement>
>   
>   <repositories>
>         <repository>
>             <id>scala-tools.org</id>
>             <url>http://artifactory.tagged.com:8081/artifactory/simple/libs-release-local</url>
>         </repository>
>         <repository>
>             <id>artifactory01.tagged.com</id>
>             <url>http://artifactory.tagged.com/artifactory/ext-release-local</url>
>         </repository>
>     </repositories>
> 
>   <build>
>     <plugins>
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <source>1.7</source>
>           <target>1.7</target>
>         </configuration>
>       </plugin>
>       <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-jar-plugin</artifactId>
>             <configuration>
>                 <archive>
>                     <manifest>
>                         <addClasspath>true</addClasspath>
>                         <mainClass>com.tagged.nib.NibShell</mainClass>
>                     </manifest>
>                 </archive>
>             </configuration>
>         </plugin>
>       <plugin>
>         <artifactId>maven-assembly-plugin</artifactId>
>         <version>2.1</version>
>         <configuration>
>           <descriptorRefs>
>             <descriptorRef>jar-with-dependencies</descriptorRef>
>           </descriptorRefs>
>         </configuration>
>       </plugin>
> 
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-resources-plugin</artifactId>
>         <configuration>
>           <encoding>UTF-8</encoding>
>         </configuration>
>       </plugin>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-source-plugin</artifactId>
>         <executions>
>           <execution>
>             <id>attach-sources</id>
>             <phase>verify</phase>
>             <goals>
>               <goal>jar</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
>   <dependencies>
>     <dependency>
>       <groupId>com.tagged</groupId>
>       <artifactId>tagged-core</artifactId>
>       <version>7.46</version>
>       <scope>compile</scope>
>     </dependency>
>     <dependency>
>       <groupId>tomcat</groupId>
>       <artifactId>servlet-api</artifactId>
>       <version>5.5.15</version>
>       <scope>provided</scope>
>     </dependency>
>     <dependency>
>       <groupId>commons-logging</groupId>
>       <artifactId>commons-logging</artifactId>
>       <version>1.1.1</version>
>       <scope>compile</scope>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.commons</groupId>
>         <artifactId>commons-lang3</artifactId>
>         <version>3.1</version>
>     </dependency>
>     <dependency>
>       <groupId>commons-httpclient</groupId>
>       <artifactId>commons-httpclient</artifactId>
>       <version>3.0.1</version>
>       <scope>compile</scope>
>     </dependency>
>     <!-- run-time dependencies -->
>     <dependency>
>       <groupId>commons-codec</groupId>
>       <artifactId>commons-codec</artifactId>
>       <version>1.4</version>
>     </dependency>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>4.5</version>
>       <scope>test</scope>
>     </dependency>
>     <dependency>
>       <groupId>mx4j</groupId>
>       <artifactId>mx4j</artifactId>
>       <version>3.0.2</version>
>     </dependency>
>     <dependency>
>         <groupId>com.tagged</groupId>
>         <artifactId>statsd-java</artifactId>
>         <version>1.0.0</version>
>     </dependency>
>     <dependency>
>         <groupId>commons-cli</groupId>
>         <artifactId>commons-cli</artifactId>
>         <version>1.2</version>
>     </dependency>
>             <!-- kafka -->
>     <dependency>
>         <groupId>kafka</groupId>
>         <artifactId>kafka</artifactId>
>         <version>0.8.0</version>
>     </dependency>
>      <dependency>
>         <groupId>kafka</groupId>
>         <artifactId>kafka-assembly-deps</artifactId>
>         <version>0.8.0</version>
>     </dependency>
>     <dependency>
>             <groupId>org.apache.zookeeper</groupId>
>             <artifactId>zookeeper</artifactId>
>             <version>3.4.5</version>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.curator</groupId>
>         <artifactId>curator-test</artifactId>
>         <version>2.4.1</version>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.curator</groupId>
>         <artifactId>curator-client</artifactId>
>         <version>2.4.1</version>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.curator</groupId>
>         <artifactId>curator-framework</artifactId>
>         <version>2.4.1</version>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.commons</groupId>
>         <artifactId>commons-math</artifactId>
>         <version>2.2</version>
>     </dependency>
>     <dependency>
>         <groupId>org.json</groupId>
>         <artifactId>json</artifactId>
>         <version>20080701</version>
>     </dependency>
>     <dependency>
>         <groupId>com.github.sgroschupf</groupId>
>             <artifactId>zkclient</artifactId>
>             <version>0.1</version>
>             <exclusions>
>                 <exclusion>
>                     <groupId>jline</groupId>
>                     <artifactId>jline</artifactId>
>                 </exclusion>
>             </exclusions>
>         </dependency>
>   </dependencies>
> </project>
> 
> 
> 
> 
> 
>> On Tue, Mar 18, 2014 at 11:35 AM, Jordan Zimmerman <jordan@jordanzimmerman.com>
wrote:
>> I’d need to see your build environment. You haven’t provided enough information.
Why are you building from source? What does your pom look like? etc.
>> 
>> -JZ
>> 
>> 
>> From: Vadim Keylis vkeylis2009@gmail.com
>> Reply: user@curator.apache.org user@curator.apache.org
>> Date: March 18, 2014 at 1:32:49 PM
>> To: user@curator.apache.org user@curator.apache.org
>> Subject:  ClassCastException when starting test server 
>> 
>>> Good morning. I just started using curator. I downloaded and compiled latest
version of curator and using zookeeper 3.4.5. I also use java 1.7. 
>>> 
>>> I embedded single line of code into my java unit test 
>>> zkServer = new TestingServer(2181);
>>> 
>>> Test crashed with exception 
>>> java.lang.ClassCastException: org.apache.zookeeper.server.NIOServerCnxn$Factory
cannot be cast to org.apache.zookeeper.server.ServerCnxnFactory
>>> at org.apache.curator.test.TestingZooKeeperMain.getServerConnectionFactory(TestingZooKeeperMain.java:138)
>>> at org.apache.curator.test.TestingZooKeeperMain.blockUntilStarted(TestingZooKeeperMain.java:83)
>>> at org.apache.curator.test.TestingZooKeeperServer.start(TestingZooKeeperServer.java:144)
>>> at org.apache.curator.test.TestingServer.<init>(TestingServer.java:75)
>>> at org.apache.curator.test.TestingServer.<init>(TestingServer.java:68)
>>> at org.apache.curator.test.TestingServer.<init>(TestingServer.java:56)
>>> at com.tagged.kafka.topic.TestTopicStream.setUp(TestTopicStream.java:47)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
>>> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
>>> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
>>> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
>>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>>> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>>> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>> 
>>> 
>>> Any suggestion?
> 

Mime
View raw message