spark2-submit抛出java.lang.NoClassDefFoundError:org / apache / hadoop / fs / FSDataInputStream

时间:2017-01-04 23:42:26

标签: hadoop apache-spark

安装spark 2.0.0后运行spark2-submit时出现以下错误。

有谁知道为什么它无法指向hadoop jar文件?当我在spark2中提及echo $HADOOP_HOME时,会显示正确的HADOOP_HOME路径。

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream
        at org.apache.spark.deploy.SparkSubmitArguments$$anonfun$mergeDefaultSparkProperties$1.apply(SparkSubmitArguments.scala:118)
        at org.apache.spark.deploy.SparkSubmitArguments$$anonfun$mergeDefaultSparkProperties$1.apply(SparkSubmitArguments.scala:118)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.deploy.SparkSubmitArguments.mergeDefaultSparkProperties(SparkSubmitArguments.scala:118)
        at org.apache.spark.deploy.SparkSubmitArguments.<init>(SparkSubmitArguments.scala:104)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:117)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.fs.FSDataInputStream
        at 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)

1 个答案:

答案 0 :(得分:0)

尝试将HADOOP_HOME / share / hadoop中的jar添加到CLASSPATH中。 比如我在/ etc / profile中添加了CLASSPATH,而我的hadoop版本是2.7.2

export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.2.jar:$HADOOP_HOME/share/hadoop/common/hadoop-common-2.7.2.jar:$HADOOP_HOME/share/hadoop/common/lib/commons-cli-1.2.jar:$CLASSPATH