运行Kafka hadoop-consumer时出现ClassNotFoundException

时间:2015-10-16 00:12:43

标签: hadoop-streaming kafka-consumer-api

我是Kafka的新手,我正在测试hortonworks sanbox 2.3。我正在关注kafka教程 https://github.com/kafka-dev/kafka/tree/master/contrib/hadoop-consumer

运行./run-class.sh时kafka.etl.impl.DataGenerator  test / test.properties,我收到错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
        at java.lang.Class.getMethod0(Class.java:2856)
        at java.lang.Class.getMethod(Class.java:1668)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
        at  sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 6 more

我已经在run-class.sh中包含了所有可能的kafka jar但仍然没有运气。请帮忙!

1 个答案:

答案 0 :(得分:0)

您缺少类 org.apache.hadoop.conf.Configuration 的jar,不是 Kafka库的一部分。它应该包含在 hadoop-common-2.5.0 中。您必须将此jar添加到类路径中。