线程" main"中的例外情况java.lang.NoClassDefFoundError:org / apache / hadoop / fs / FSDataInputStream

时间:2017-03-27 09:39:18

标签: hadoop apache-spark

我正在向Hadoop集群提交远程火花作业。但是得到以下错误消息可以帮我解决这个问题。

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream
    at org.apache.spark.Logging$.<init>(Logging.scala:162)
    at org.apache.spark.Logging$.<clinit>(Logging.scala)
    at org.apache.spark.Logging$class.initializeIfNecessary(Logging.scala:103)
    at org.apache.spark.Logging$class.log(Logging.scala:50)
    at org.apache.spark.deploy.yarn.ApplicationMaster$.log(ApplicationMaster.scala:635)
    at org.apache.spark.deploy.yarn.ApplicationMaster$.main(ApplicationMaster.scala:649)
    at org.apache.spark.deploy.yarn.ExecutorLauncher$.main(ApplicationMaster.scala:674)
    at org.apache.spark.deploy.yarn.ExecutorLauncher.main(ApplicationMaster.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)
    ... 8 more

3 个答案:

答案 0 :(得分:0)

您似乎正在使用为用户提供的Hadoop预先构建的Spark发行版。尝试下载一个说明&#34;为Hadoop 2.x或更高版本&#34;预先构建的发行版,其中x将是您现有的Hadoop集群版本,并查看它是否适合您。

答案 1 :(得分:0)

问题在于类路径。

我已将以下代码添加到应用程序中,它解决了问题:

.set("spark.hadoop.yarn.application.classpath",
                                     "/etc/hadoop/conf,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop/lib/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-hdfs/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-hdfs/lib/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-mapreduce/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-mapreduce/lib/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-yarn/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/hadoop-yarn/lib/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/spark/*,"
                                             + "/opt/cloudera/parcels/CDH-5.7.1-1.cdh5.7.1.p0.11/lib/spark/lib/*")

答案 2 :(得分:0)

要解决此问题,请使用以下命令运行spark:

/usr/local/spark/bin/spark-shell