报错内容:
masterUrl:spark://192.168.43.110:7077, inputPath: c:\sparkdata\hamlet.txt, outputPath: c:\sparkdataException in thread "main" java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;at org.apache.spark.internal.config.ConfigHelpers$.stringToSeq(ConfigBuilder.scala:48)at org.apache.spark.internal.config.TypedConfigBuilder$$anonfun$toSequence$1.apply(ConfigBuilder.scala:124)at org.apache.spark.internal.config.TypedConfigBuilder$$anonfun$toSequence$1.apply(ConfigBuilder.scala:124)at org.apache.spark.internal.config.TypedConfigBuilder.createWithDefault(ConfigBuilder.scala:142)at org.apache.spark.internal.config.package$.(package.scala:152)at org.apache.spark.internal.config.package$.(package.scala)at org.apache.spark.SparkConf$.(SparkConf.scala:668)at org.apache.spark.SparkConf$.(SparkConf.scala)
at org.apache.spark.SparkConf.set(SparkConf.scala:94)
at org.apache.spark.SparkConf.set(SparkConf.scala:83)
at org.apache.spark.SparkConf.setAppName(SparkConf.scala:120)
at cn.goingtodo.WordCount$.main(WordCount.scala:22)
at cn.goingtodo.WordCount.main(WordCount.scala)
Process finished with exit code 1
scala代码:
package cn.goingtodo
import org.apache.spark.{SparkConf, SparkContext}
object WordCount {
def main(args: Array[String]) {
// var masterUrl = "192.168.43.110"
var masterUrl ="spark://192.168.43.110:7077"
var inputPath ="c:\\sparkdata\\hamlet.txt"
var outputPath ="c:\\sparkdata"
if (args.length ==1) {
masterUrl = args(0)
}else if (args.length ==3) {
masterUrl = args(0)
inputPath = args(1)
outputPath = args(2)
}
println(s"masterUrl:${masterUrl}, inputPath: ${inputPath}, outputPath: ${outputPath}")
val sparkConf =new SparkConf().setAppName("WordCount").setMaster(masterUrl)
val sc =new SparkContext(sparkConf)
val rowRdd = sc.textFile(inputPath)
val resultRdd = rowRdd.flatMap(line => line.split("\\s+")) .map(word => (word, 1)).reduceByKey(_ + _)
resultRdd.saveAsTextFile(outputPath)
}
}
页面信息
http://192.168.43.110:8080
spark://192.168.43.110:7077
URL:spark://192.168.43.110:7077
REST URL:spark://192.168.43.110:6066(cluster mode)
Workers:0
Cores:0 Total, 0 Used
Memory:0.0 B Total, 0.0 B Used
Applications:0 Running, 0 Completed
Drivers:0 Running, 0 Completed
Status:ALIVE