2016-10-24 19 views
0

私は、Apacheカフカを実装しようとの統合 ストリーミングスパークしていますここに私のpythonのコードは次のとおりです。

from __future__ import print_function 
import sys 
from pyspark.streaming import StreamingContext 
from pyspark import SparkContext,SparkConf 
from pyspark.streaming.kafka import KafkaUtils 

if __name__ == "__main__": 
#conf = SparkConf().setAppName("Kafka-Spark").setMaster("spark://127.0.0.1:7077") 
conf = SparkConf().setAppName("Kafka-Spark") 
#sc = SparkContext(appName="KafkaSpark") 
sc = SparkContext(conf=conf) 
stream=StreamingContext(sc,1) 
map1={'demo':1} 
kafkaStream = KafkaUtils.createStream(stream, 'localhost:2181', "test-consumer-group", map1) 

# kafkaStream = KafkaUtils.createStream(stream, 'localhost:2181', "name", map1) #tried with localhost:2181 too 
lines = kafkaStream.map(lambda x: x[1]) 
counts = lines.flatMap(lambda line: line.split(" ")) 
    .map(lambda word: (word, 1)) \ 
    .reduceByKey(lambda a, b: a+b) 
counts.pprint() 

stream.start() 
stream.awaitTermination() 

私はプログラム上で実行すると、それは出力を表示端末上:段階におけるタスク0.0での例外0.0(TID 0) java.lang.NoClassDefFoundErrorが:Scalaの/コレクション/ GenTraversableOnceの$クラス kafka.utilsでキュータ

16/10/24午後3時27分20秒ERROR .Pool。(Pool.scala:28) kafka.consumer.ZookeeperConsumerConnでエクター(ZookeeperConsumerConnector.scala:91)。 kafka.consumer.ZookeeperConsumerConnectorで(ZookeeperConsumerConnector.scala:143)。 kafka.consumer.Consumer $ .createで(ConsumerConnector.scala:94) org.apache.spark.streamingで.kafka.KafkaReceiver.onStart(KafkaInputDStream.scala:100) at org.apache.spark.streaming.receiver.ReceiverSupervisor.startReceiver(ReceiverSupervisor.scala:149) at org.apache.spark.streaming.receiver.ReceiverSupervisor.start (ReceiverSupervisor.scala:131) at org.apache.spark.streaming.scheduler.ReceiverTracker $ ReceiverTrackerEndpoint $$ anonfun $ 9.apply(ReceiverTracker.scala:597) at org.apache.spark.streaming.scheduler.ReceiverTracker $ ReceiverTrackerEndpoint $$ anonfun $ 9.apply(ReceiverTracker.scala:587) at org.apache。 SparkContext $$ anonfun $ 33.apply(SparkContext.scala:1993) at org.apache.spark.SparkContext $$ anonfun $ 33.apply(SparkContext.scala:1993) at org.apache.spark.scheduler.ResultTask。 (Executor.scala:274)runTask(ResultTask.scala:70) at org.apache.spark.scheduler.Task.run(Task.scala:86) at org.apache.spark.executor.Executor $ TaskRunner.run (ThreadPoolExecutor.java:1142) のjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) のjava.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) のjava.lang.Thread.run(スレッド。 java:745) 原因:java.lang.ClassNotFoundException:scala.collection.GenTraversableOnce $ class java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 17 more 16/10/24 15:27:20エラーSparkUncaughtExceptionHandler:スレッド内のキャッチされていない例外[Executor task launch worker-0,5、main] java.lang.NoClassDefFoundError:scala/collection/GenTraversableOnce $ kafka.utils.Poolでクラス (Pool.scala:28)。 kafka.consumer.ZookeeperConsumerConnectorで(ZookeeperConsumerConnector.scala:91)。 kafka.consumer.ZookeeperConsumerConnectorで(ZookeeperConsumerConnector.scala:143)。カフカで 。 consumer.Consumer $ .create(ConsumerConnector.scala:94)(KafkaInputDStream.scala:100) at org.apache.spark.streaming.receiver.ReceiverSupervisor.startReceiver(ReceiverSupervisor.scala:149) at org.apache。 (ReceiverTracker.scala:597) at org.apache。 Spark.streaming.scheduler.ReleaseiverTracker $ ReceiverTrackerEndpoint $$ anonfun $ 9.apply(ReceiverTracker.scala:587) at org.apache.spark.SparkContext $$ anonfun $ 33.apply(SparkContext.scala:1993) at org.apache。 spark.SparkContext $$ anonfun $ 33.apply(SparkContext.scala:1993) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask。スケーラ:70) at org.apache.spark.scheduler.Task.run(Task.scala:86) at org.apache.spark.executor.Executor $ TaskRunner.run(Executor.scala:274) at java。 (ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)でのutil.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) のjava.util.concurrent.ThreadPoolExecutor $ Worker.run によって引き起こさ:java.lang.ClassNotFoundExceptionが:java.lang.ClassLoader.loadClass(ClassLoader.java:424)でjava.net.URLClassLoader.findClass(URLClassLoader.java:381) でscala.collection.GenTraversableOnceの$クラス at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 17 more 16/10/24 15:27:20 INFO StreamingContext:シャットダウンフックからstop(stopGracefully = false)を呼び出す 16/10/24 15:27:20 WARN TaskSetManager:ステージ0.0でタスク0.0を失った(ZookeeperConsumerConnector.scala:91)のkafka.consumer.ZookeeperConsumerConnectorの kafka.utils.Pool(Pool.scala:28) のスケーラ/コレクション/ GenTraversableOnce $クラス でのjava.lang.NoClassDefFoundError: kafka.consumer.ZookeeperConsumerConnectorで (ZookeeperConsumerConnector.scala:143)。 kafka.consumer.Consumer $ .createで(ConsumerConnector.scala:94) org.apache.spark.streaming.kafka.KafkaReceiver.onStartで(KafkaInputDStream。スカラー:100) at org.apache.spark.streaming.receiver.ReceiverSupervisor.startReceiver(ReceiverSup ervice.scala:149) at org.apache.spark.streaming.receiver.ReceiverSupervisor.start(ReceiverSupervisor.scala:131) at org.apache.spark.streaming.scheduler.ReceiverTracker $ ReceiverTrackerEndpoint $$ anonfun $ 9.apply (ReceiverTracker.scala:597) at org.apache.spark.streaming.scheduler.ReceiverTracker $ ReceiverTrackerEndpoint $$ anonfun $ 9.apply(ReceiverTracker.scala:587) at org.apache.spark.SparkContext $$ anonfun $ 33.apply SparkContext.scala:1993) at org.apache.spark.SparkContext $$ anonfun $ 33.apply(SparkContext.scala:1993) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:70) at org.apache.spark.scheduler.Task.run(Task.scala:86) at org.apache.spark.executor.Executor $ TaskRunner.run(Executor.scala:274) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(スレッド。 java:745) 原因:java.lang.ClassNotFoundException:scala.collection.GenTraversableOnce $ class at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java :424)sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:331)java.lang.ClassLoader.loadClass(ClassLoader.java:357) で で ...もっと17

16/10/24 15:27:20エラーTaskSetManager:ステージ0.0のタスク0 f 1回腐食;

答えて

0

コレクションAPIはScalaの2.10と2.11

<dependency> 
        <groupId>org.scala-lang</groupId> 
        <artifactId>scala-library</artifactId> 
        <version>2.10.6</version> 
    </dependency> 
の間で異なっています
関連する問題