java.lang.NoClassDefFoundError: scala/xml/MetaData

我在ide里面运行一个spark的程序,代码如下:

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;

public class testSpark {
    public static void main(String[] args) {
        SparkConf conf = new SparkConf().setAppName("Testing").setMaster("local");
        JavaSparkContext sc = new JavaSparkContext(conf);

        System.out.println(sc.appName());
    }
}

但是当我运行的时候报错了:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/xml/MetaData 
	at org.apache.spark.ui.jobs.JobsTab.(JobsTab.scala:30) 
	at org.apache.spark.ui.SparkUI.initialize(SparkUI.scala:50) 
	at org.apache.spark.ui.SparkUI.(SparkUI.scala:61) 
	at iScope.testSpark.main(testSpark.java:9)
Caused by: java.lang.ClassNotFoundException: scala.xml.MetaData 
	at java.net.URLClassLoader.findClass(Unknown Source) 
	at java.lang.ClassLoader.loadClass(Unknown Source)
我的pom文件:


	org.apache.spark
	spark-core_2.11
	1.2.1


	com.google.guava
	guava
	18.0


	org.apache.spark
	spark-mllib_2.11
	1.2.1

解决办法是在pom文件中引入scala.xml的jar包:


    org.scala-lang
    scala-xml
    2.11.0-M4


原文地址: https://stackoverflow.com/questions/30049797/noclassdeffound-scala-xml-metadata

你可能感兴趣的:(scala)