播放框架在启动时挂起:“正在加载项目定义”

Posted

技术标签:

【中文标题】播放框架在启动时挂起:“正在加载项目定义”【英文标题】:Play framework hangs on startup at: "Loading project definition from" 【发布时间】:2012-07-07 13:57:21 【问题描述】:

我刚刚开始使用 Play Framework。我已经下载并安装了 play 并创建了一个示例 java 应用程序。当我尝试在应用程序目录中启动播放控制台时,它会挂在“正在加载项目定义”。

PS C:\dev\play\javatest> play.bat
Getting org.scala-sbt sbt_2.9.1 0.11.3 ...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        37 artifacts copied, 0 already retrieved (7245kB/283ms)
[info] Loading project definition from C:\dev\play\myFirstApp\project

当我尝试运行一个 Scala 应用程序时,我收到一条关于它正在等待锁定的消息:

PS C:\dev\play\scalatest> play
[info] Loading project definition from C:\dev\play\test1\project
Waiting for lock on C:\lib\play\repository\.sbt.ivy.lock to be available...

运行 Windows 7、JDK 1.7.0_05 和 Play Framework 2.0.2。有什么想法吗?

【问题讨论】:

【参考方案1】:

我刚刚在 Play 2 中亲身体验了这一点,结果发现它并没有真正挂起,它只是拉一个 maven 并下载 Internet。要验证这与您遇到的行为相同,请编辑 project/plugins.sbt 并替换:

logLevel := Level.Warn

logLevel := Level.Debug

(虽然我是在 OSX 上构建的,但我想你会在 Windows 上体验到类似的输出。)

【讨论】:

+1 因为当我读完这篇文章时,我的互联网已经完全下载,我的项目也打开了 重要的是要注意 IntelliJ 13 的最新版本支持 sbt 项目 [适用于 Scala Play 项目] 这意味着同时使用控制台 sbt 会话和 IntelliJ 可能会导致很多 @987654324 @ 等待消息,因为两个环境在解决依赖关系时竞争更新 ivy 存储库。 解释清楚。谢谢。【参考方案2】:

只是为了在此处添加现有答案,

从 Play 2.2x 升级到 Play 2.3.x 后,我也看到了这种行为(请参阅 MigrationGuide)

我正在调试如下。

在 Linux 上,转到您的项目文件夹,然后:

$ bash -x `which sbt`
.... OUTPUT SKIPPED....
++ ((  128 < 512  ))
++ local 'common_opts=-Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m'
++ [[ 1.7.0_55 < 1.8 ]]
++ local perm=256
++ echo '-Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=256m'
+ execRunner java -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=256m -jar /usr/share/sbt-launcher-packaging/bin/sbt-launch.jar
+ [[ -n '' ]]
+ [[ -n '' ]]
+ java -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=256m -jar /usr/share/sbt-launcher-packaging/bin/sbt-launch.jar

记下最后一行的命令,取消当前进程Ctrl+C,并在java添加-verbose选项执行它:

java -verbose -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=256m -jar /usr/share/sbt-launcher-packaging/bin/sbt-launch.jar

最后我还在project/plugins.sbt中添加了logLevel := Level.Debug

但是,它不断给出这样的输出:

.... OUTPUT SKIPPED....
info]   [SUCCESSFUL ] org.apache.maven.doxia#doxia-sink-api;1.1!doxia-sink-api.jar (2065ms)
[debug]         tried http://repo.typesafe.com/typesafe/ivy-releases/org.apache.maven.doxia/doxia-logging-api/1.1/jars/doxia-logging-api.jar
[debug] CLIENT ERROR: Not Found url=http://repo.typesafe.com/typesafe/ivy-releases/org.apache.maven.doxia/doxia-logging-api/1.1/jars/doxia-logging-api.jar
[debug]         tried http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.maven.doxia/doxia-logging-api/1.1/jars/doxia-logging-api.jar
[debug] CLIENT ERROR: Not Found url=http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.maven.doxia/doxia-logging-api/1.1/jars/doxia-logging-api.jar
[debug]         tried /home/saleem/.ivy2/local/org.apache.maven.doxia/doxia-logging-api/1.1/jars/doxia-logging-api.jar
[debug]         tried http://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[info] downloading http://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar ...
[debug]     public: downloading http://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[debug]     public: downloading http://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar.sha1
[debug] sha1 OK for http://repo1.maven.org/maven2/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[info]  [SUCCESSFUL ] org.apache.maven.doxia#doxia-logging-api;1.1!doxia-logging-api.jar (3997ms)
[debug]         tried http://repo.typesafe.com/typesafe/ivy-releases/org.apache.maven/maven-plugin-registry/2.2.1/jars/maven-plugin-registry.jar
[debug] CLIENT ERROR: Not Found url=http://repo.typesafe.com/typesafe/ivy-releases/org.apache.maven/maven-plugin-registry/2.2.1/jars/maven-plugin-registry.jar
[debug]         tried http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.maven/maven-plugin-registry/2.2.1/jars/maven-plugin-registry.jar
[debug] CLIENT ERROR: Not Found url=http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.maven/maven-plugin-registry/2.2.1/jars/maven-plugin-registry.jar
[debug]         tried /home/saleem/.ivy2/local/org.apache.maven/maven-plugin-registry/2.2.1/jars/maven-plugin-registry.jar
[debug]         tried http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar
[info] downloading http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar ...
[debug]     public: downloading http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar
[debug]     public: downloading http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar.sha1
[debug] sha1 OK for http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar
[info]  [SUCCESSFUL ] org.apache.maven#maven-plugin-registry;2.2.1!maven-plugin-registry.jar (2025ms)
[debug]         tried http://repo.typesafe.com/typesafe/ivy-releases/backport-util-concurrent/backport-util-concurrent/3.1/jars/backport-util-concurrent.jar
[debug] CLIENT ERROR: Not Found url=http://repo.typesafe.com/typesafe/ivy-releases/backport-util-concurrent/backport-util-concurrent/3.1/jars/backport-util-concurrent.jar
[debug]         tried http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/backport-util-concurrent/backport-util-concurrent/3.1/jars/backport-util-concurrent.jar
[debug] CLIENT ERROR: Not Found url=http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/backport-util-concurrent/backport-util-concurrent/3.1/jars/backport-util-concurrent.jar
[debug]         tried /home/saleem/.ivy2/local/backport-util-concurrent/backport-util-concurrent/3.1/jars/backport-util-concurrent.jar
[debug]         tried http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[info] downloading http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar ...
[debug]     public: downloading http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
.... OUTPUT SKIPPED....

似乎要下载的 jar 太多。我现在正在使用 Typesafe Activator 的离线版本(356MB 下载here),而且速度要快得多!

【讨论】:

此回复中的调试说明非常有用。我使用bash -x "$(which sbt)" 发现http.proxyHosthttp.proxyPort 是从环境中提取的,导致工件解析失败(由于sbt repo 是公司内部的,确实需要 通过代理)。谢谢!【参考方案3】:

尝试中止构建,删除引用的锁定文件,然后再次执行“播放运行”。

【讨论】:

以上是关于播放框架在启动时挂起:“正在加载项目定义”的主要内容,如果未能解决你的问题,请参考以下文章

Xcode 8 在加载时挂起

Ruby on Rails 控制台在加载时挂起

XCode 8在加载时挂起

Spring Boot Reactive Mongo 在启动时挂起

如何防止 Eclipse 在启动时挂起?

Facebook iOS SDK 在应用启动时挂起