【发布时间】:2014-09-24 22:42:41
【问题描述】:
我正在尝试在 Spark Shell 中使用 twitterUtils(默认情况下它们不可用)。
我已将以下内容添加到spark-env.sh:
SPARK_CLASSPATH="/disk.b/spark-master-2014-07-28/external/twitter/target/spark-streaming-twitter_2.10-1.1.0-SNAPSHOT.jar"
我现在可以执行了
import org.apache.spark.streaming.twitter._
import org.apache.spark.streaming.StreamingContext._
shell 中没有错误,如果不将 jar 添加到类路径中,这是不可能的(“错误:对象 twitter 不是包 org.apache.spark.streaming 的成员”)。 但是,在 Spark shell 中执行此操作时会出现错误:
scala> val ssc = new StreamingContext(sc, Seconds(1))
ssc: org.apache.spark.streaming.StreamingContext =
org.apache.spark.streaming.StreamingContext@6e78177b
scala> val tweets = TwitterUtils.createStream(ssc, "twitter.txt")
error: bad symbolic reference. A signature in TwitterUtils.class refers to
term twitter4j in package <root> which is not available.
It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling
TwitterUtils.class.
我错过了什么?我必须导入另一个 jar 吗?
【问题讨论】:
标签: apache-spark