使用SBT构建Apache Spark:无效或损坏的jarfile

Bla*_*ack 11 scala sbt apache-spark apache-spark-1.4

我正在尝试在我的本地计算机上安装Spark.我一直在关注这个指南.我已安装JDK-7(也有JDK-8)和Scala 2.11.7.当我尝试使用sbt构建时出现问题Spark 1.4.1.我得到以下异常.

NOTE: The sbt/sbt script has been relocated to build/sbt.
      Please update references to point to the new location.

      Invoking 'build/sbt assembly' now ...

Attempting to fetch sbt
Launching sbt from build/sbt-launch-0.13.7.jar
Error: Invalid or corrupt jarfile build/sbt-launch-0.13.7.jar
Run Code Online (Sandbox Code Playgroud)

我已经找到了解决这个问题的方法.我找到了一个很好的指南/sf/answers/2211809841/,它使用了预建版本.除了使用预建版本,有没有办法安装Spark使用sbt?此外,是否有原因导致Invalid or corrupt jarfile错误发生?

小智 18

我遇到了同样的问题.我现在修好了.

这可能是因为sbt-launch-0.13.7.jar下载失败,虽然你可以看到该文件存在,但它不是正确的文件.该文件大小约为1.2MB.如果小于,你可以进入build /,使用"vim sbt-launch-0.13.7.jar"或其他工具打开sbt-launch-0.13.7.jar文件.

如果文件包含如下内容:

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这意味着不会下载sbt-launch-0.13.7.jar.然后在同一目录中打开sbt-launch-lib.bash,检查第41行和第42行,它给出了两个url.打开它以检查它们是否运行良好.

如果url1不起作用,手动下载sbt-launch.jar(你可以使用url2,它可以工作,或者你可以从sbt官方网站下载),把它放在同一目录下,重命名为sbt-launch-0.13 .7.jar,然后你就下载相关的评论行(可能在47行和68行之间),避免脚本再次下载.像这样:

acquire_sbt_jar () {
  SBT_VERSION=`awk -F "=" '/sbt\.version/ {print $2}'    ./project/build.properties`
  URL1=http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
  URL2=http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
  JAR=build/sbt-launch-${SBT_VERSION}.jar

  sbt_jar=$JAR

 # if [[ ! -f "$sbt_jar" ]]; then
 #   # Download sbt launch jar if it hasn't been downloaded yet
 #   if [ ! -f "${JAR}" ]; then
 #   # Download
 #   printf "Attempting to fetch sbt\n"
 #   JAR_DL="${JAR}.part"
 #   if [ $(command -v curl) ]; then
 #     (curl --silent ${URL1} > "${JAR_DL}" || curl --silent ${URL2} > "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
 #   elif [ $(command -v wget) ]; then
 #     (wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
 #   else
 #     printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"
 #     exit -1
 #   fi
 #   fi
 #   if [ ! -f "${JAR}" ]; then
 #   # We failed to download
 #   printf "Our attempt to download sbt locally to ${JAR} failed. Please install sbt manually from http://www.scala-sbt.org/\n"
 #   exit -1
 #   fi
 #   printf "Launching sbt from ${JAR}\n"
 # fi
 }
Run Code Online (Sandbox Code Playgroud)

然后使用"build/sbt assembly"再次构建火花.

希望你会成功.

如果我没有明确表达,以下链接可能会有所帮助.

https://www.mail-archive.com/user@spark.apache.org/msg34358.html

错误:无效或损坏jarfile sbt/sbt-launch-0.13.5.jar prabeesh 的答案

https://groups.google.com/forum/#!topic/predictionio-user/fllCh8n-0d4

  • 这是一个非常类似Spark的事情. (4认同)