在Scala程序中获取java.lang.NoClassDefFoundError:scala / xml / MetaData错误

时间:2018-10-30 05:10:51

标签: scala apache-spark avro

我正在尝试使用Scala中的spark将数据保存到avro文件中,但低于Exception

 Exception in thread "main" java.lang.NoClassDefFoundError: scala/xml/MetaData
    at org.apache.spark.ui.jobs.StagesTab.<init>(StagesTab.scala:33)
    at org.apache.spark.ui.SparkUI.<init>(SparkUI.scala:62)
    at org.apache.spark.ui.SparkUI$.create(SparkUI.scala:215)
    at org.apache.spark.ui.SparkUI$.createLiveUI(SparkUI.scala:157)
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:443)
    at tavant.user.UserData$.main(UserData.scala:18)
    at tavant.user.UserData.main(UserData.scala)
Caused by: java.lang.ClassNotFoundException: scala.xml.MetaData
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more

下面是我的pom.xml依赖项

 <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.7</version>
   </dependency>
   <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-sql_2.10</artifactId>
        <version>2.2.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.10</artifactId>
        <version>2.0.0-cloudera1-SNAPSHOT</version>
    </dependency>

我尝试了其他解决方案,例如向我的pom.xml文件添加依赖项,以下是我尝试过的依赖项:

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-xml</artifactId>
<version>2.11.0-M4</version>

但是要低于异常

Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.$scope()Lscala/xml/TopScope$;
at org.apache.spark.ui.jobs.StagePage.<init>(StagePage.scala:44)
at org.apache.spark.ui.jobs.StagesTab.<init>(StagesTab.scala:34)
at org.apache.spark.ui.SparkUI.<init>(SparkUI.scala:62)
at org.apache.spark.ui.SparkUI$.create(SparkUI.scala:215)
at org.apache.spark.ui.SparkUI$.createLiveUI(SparkUI.scala:157)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:443)
at tavant.user.UserData$.main(UserData.scala:18)
at tavant.user.UserData.main(UserData.scala)

任何想法?? 预先感谢

0 个答案:

没有答案