线程“main”java.lang.noclassdeffounderror中出现异常:org/apache/hadoop/fs/fsdatainputstream

xnifntxz  于 2021-05-29  发布在  Hadoop
关注(0)|答案(3)|浏览(602)

我正在向hadoop集群提交远程spark作业。但是下面的错误信息可以帮助我解决这个问题。

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
bf1o4zei

bf1o4zei1#

看起来您使用的是为用户提供的hadoop预先构建的spark发行版。试着下载一个发行版,上面写着“pre-buildforhadoop2.x或更高版本”,其中x是您现有的hadoopcluster版本,看看它是否适合您。

yhqotfr8

yhqotfr82#

问题出在类路径上。
我在应用程序中添加了以下代码,解决了这个问题:

.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/*")
332nm8kg

332nm8kg3#

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

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

相关问题