11

我正在尝试在我的本地机器上安装 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

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

4

2 回答 2

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>

这意味着没有下载 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
 }

然后使用“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

于 2015-08-08T10:23:21.380 回答
0

手动下载sbt-launch.jar文件(可以使用url2,应该可以,也可以到sbt官网下载),放到同一个目录下,重命名为sbt-launch-0.13.7.jar,然后运行 ​​sbt/sbt 汇编命令。

于 2015-12-25T11:58:29.947 回答