Hi Dave, Here's a POM I use to build the examples. It's pretty simple, including kafka 0.8.0 with scala 2.9.2 libs, and targeting Java 7. I also made a couple of mods to make things easier:
1) I use log4j 1.2.17 to eliminate a log4j 1.2.15 dependency on the sun jdmk. 2) I use the maven dependency plugin to build a lib folder that has all the jars you need for the runtime classpath. Hope it helps, Steve On Tue, May 6, 2014 at 8:11 AM, David Novogrodsky < [email protected]> wrote: > All, > > I am running some examples from the packet book Apache Kafka. I am > creating a HighLevelconsumer. I am getting an error when I try to run the > code: > -- > C:\Users\david.j.novogrodsky\Documents\TestingKafka\target>java -cp > Kafka_test-1.0-SNAPSHOT.jar com.cat.HighLevelConsumer test > Exception in thread "main" java.lang.NoClassDefFoundError: > kafka/consumer/ConsumerConfig > at com.cat.HighLevelConsumer.<init>(HighLevelConsumer.java:32) > at com.cat.HighLevelConsumer.main(HighLevelConsumer.java:61) > Caused by: java.lang.ClassNotFoundException: kafka.consumer.ConsumerConfig > at java.net.URLClassLoader$1.run(Unknown Source) > at java.net.URLClassLoader$1.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(Unknown Source) > at java.lang.ClassLoader.loadClass(Unknown Source) > at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) > at java.lang.ClassLoader.loadClass(Unknown Source) > -- > Is this an error with the POM? > David Novogrodsky > [email protected] > http://www.linkedin.com/in/davidnovogrodsky > -- Steve Robenalt Software Architect HighWire | Stanford University 425 Broadway St, Redwood City, CA 94063 [email protected] http://highwire.stanford.edu
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example.kafka.test</groupId> <artifactId>org.example.kafka.test</artifactId> <version>0.2.0-SNAPSHOT</version> <name>kafkatest</name> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <includeScope>runtime</includeScope> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.9.2</artifactId> <version>0.8.0</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> </dependencies> </project>
