sbt错误WordCount中的ClassNotFoundException

时间:2018-03-09 18:00:45

标签: scala intellij-idea sbt intellij-14 sbt-plugin

这可能是一个新手问题,但我试图在intellij中学习更多关于scala的知识。我首先创建了一个工作正常的简单HelloWorld项目。接下来我看了一个创建WordCount项目的教程,但是我得到的异常错误是我无法弄清楚的。 我得到的错误是:

Error:Error while importing SBT project:<br/>...<br/><pre>
[error] at 
sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:107)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:101)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:57)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:42)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:34)
[error] at sbt.StandardMain$.runManaged(Main.scala:113)
[error] at sbt.xMain.run(Main.scala:76)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.ClassNotFoundException: 
org.jetbrains.sbt.CreateTasks$
[error] Use 'last' for the full log.
[info] shutting down server

我的build.sbt文件是:

  name := "Scalaprogramms"
  version := "1.0"
  scalaVersion:="2.11.8"
  libraryDependencies += "org.apache.spark" %% "spark-core" % "2.2.0"
  libraryDependencies += "org.apache.spark" %% "spark-streaming" % "2.2.0" % "provided"

我的java版本是8

最后一个日志文件是

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=384M; 
support was removed in 8.0
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from 
/home/user/IdeaProjects/Scalaprogramms/project
[info] Loading settings from build.sbt ...
[info] Set current project to Scalaprogramms (in build 
file:/home/user/IdeaProjects/Scalaprogramms/)
[info] sbt server started at 
local:///home/user/.sbt/1.0/server/fc2d3f3386938f38b259/sock
sbt:Scalaprogramms>
[info] Defining Global / sbtStructureOptions, Global / 
sbtStructureOutputFile, shellPrompt
[info] The new values will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to Scalaprogramms (in build 
file:/home/user/IdeaProjects/Scalaprogramms/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks 
from /home/user/.IdeaIC2017.2/config/plugins/Scala/launcher/sbt-
structure-1.1.jar
[error] java.lang.ClassNotFoundException: 
org.jetbrains.sbt.CreateTasks$
[error] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error] at java.lang.Class.forName0(Native Method)
[error] at java.lang.Class.forName(Class.java:348)
[error] at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:20)
[error] at  sbt.BasicCommands$.$anonfun$call$5(BasicCommands.scala:203)
[error] at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error] at scala.collection.immutable.List.foreach(List.scala:389)
[error] at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error] at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error] at scala.collection.immutable.List.map(List.scala:295)
[error] at sbt.BasicCommands$.$anonfun$call$2(BasicCommands.scala:203)
[error] at sbt.Command$.$anonfun$applyEffect$4(Command.scala:134)
[error] at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error] at sbt.MainLoop$.processCommand(MainLoop.scala:153)
[error] at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:136)
[error] at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error] at sbt.State$$anon$1.process(State.scala:248)
[error] at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:136)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.MainLoop$.next(MainLoop.scala:136)
[error] at sbt.MainLoop$.run(MainLoop.scala:129)
[error] at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:107)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:101)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:57)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:42)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:34)
[error] at sbt.StandardMain$.runManaged(Main.scala:113)
[error] at sbt.xMain.run(Main.scala:76)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.ClassNotFoundException: org.jetbrains.sbt.CreateTasks$
[error] Use 'last' for the full log.
[info] shutting down server

另外,我的代码是:

package scala.SparkApps
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object WordCount {
    def main(args: Array[String]): Unit = {
        val inputFile = args(0)
        val outputFile = args(1)
        val conf = new SparkConf().setMaster("local(*)").setAppName("wordcount")
        val sc = new SparkContext(Conf)
        val input = sc.textFile(inputFile)
        val words = input.flatMap(_.split(" "))
        val counts = words.map(word => (word, 1)).reduceByKey(_+_)
        counts.saveAsTextFile(outputFile)
    }
}

有什么想法吗?

0 个答案:

没有答案