编译我的play框架应用程序时遇到了一些问题。有时应用程序运行正常,但大多数时候这些问题都发生在sbt和activator工具上。以下是使用sbt编译我的应用程序的示例:
[info] Compiling 15 Scala sources and 1 Java source to C:\Server\trunk\target\scala-2.11\classes...
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:8: error: cannot find symbol
[error] public static final controllers.ReverseAssets Assets = new controllers.ReverseAssets();
[error] ^
[error] symbol: class ReverseAssets
[error] location: package controllers
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:9: error: cannot find symbol
[error] public static final controllers.ReverseApplication Application = new controllers.ReverseApplication();
[error] ^
[error] symbol: class ReverseApplication
[error] location: package controllers
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:12: error: package controllers.javascript does not exist
[error] public static final controllers.javascript.ReverseAssets Assets = new controllers.javascript.ReverseAssets();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:13: error: package controllers.javascript does not exist
[error] public static final controllers.javascript.ReverseApplication Application = new controllers.javascript.ReverseApplication();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:18: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseAssets Assets = new controllers.ref.ReverseAssets();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:19: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseApplication Application = new controllers.ref.ReverseApplication();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:8: error: cannot find symbol
[error] public static final controllers.ReverseAssets Assets = new controllers.ReverseAssets();
[error] ^
[error] symbol: class ReverseAssets
[error] location: package controllers
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:9: error: cannot find symbol
[error] public static final controllers.ReverseApplication Application = new controllers.ReverseApplication();
[error] ^
[error] symbol: class ReverseApplication
[error] location: package controllers
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:12: error: package controllers.javascript does not exist
[error] public static final controllers.javascript.ReverseAssets Assets = new controllers.javascript.ReverseAssets();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:13: error: package controllers.javascript does not exist
[error] public static final controllers.javascript.ReverseApplication Application = new controllers.javascript.ReverseApplication();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:18: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseAssets Assets = new controllers.ref.ReverseAssets();
[error] ^
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:19: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseApplication Application = new controllers.ref.ReverseApplication();
[error] ^
[error] 12 errors
[error] (compile:compile) javac returned nonzero exit code
[error] Total time: 16 s, completed Oct 31, 2014 11:18:25 AM
其他时候我会用sbt clean compile得到这个错误:
[info] Compiling 15 Scala sources and 1 Java source to C:\Server\trunk\target\scala-2.11\classes...
[trace] Stack trace suppressed: run last compile:compile for the full output.
[error] (compile:compile) java.lang.NoClassDefFoundError: Lcontrollers/ReverseAssets;
[error] Total time: 45 s, completed Oct 31, 2014 11:45:49 AM
然后我将退出sbt然后再次运行sbt clean编译,一切似乎编译正常。我甚至会运行激活器运行,一切都编译好但没有一条路线被识别出来:
# Home page
GET / controllers.Application.index
GET /login controllers.Application.login
然后我会在使用激活器运行时编译错误:
[info] Compiling 15 Scala sources and 1 Java source to C:\Server\trunk\target\scala-2.11\classes...
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:13: error: cannot find symbol
[error] public static final controllers.javascript.ReverseApplication Application = new controllers.javascript.ReverseApplication()
[error] ^
[error] symbol: class ReverseApplication
[error] location: package controllers.javascript
[error] C:\Server\trunk\target\scala-2.11\src_managed\main\controllers\routes.java:13: error: cannot find symbol
[error] public static final controllers.javascript.ReverseApplication Application = new controllers.javascript.ReverseApplication()
[error] ^
[error] symbol: class ReverseApplication
[error] location: package controllers.javascript
[error] 2 errors
[error] (compile:compile) javac returned nonzero exit code
[error] application -
! @6k3l8fool - Internal server error, for (GET) [/] ->
play.PlayExceptions$CompilationException: Compilation error[error: cannot find symbol]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:235) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:230) ~[na:na]
[warn] play - No application found at invoker init
然后我运行激活器清理运行,我得到一个完全不同的错误:
[info] Compiling 15 Scala sources and 1 Java source to C:\Server\trunk\target\scala-2.11\classes...
java.lang.IllegalArgumentException: requirement failed: Source file 'C:\Server\trunk\target\scala-2.11\classes\Routes$$anonfun$routes$1$$anonfun$applyOrElse$4.class' does not exist.
at scala.Predef$.require(Predef.scala:233)
at sbt.IO$.copyFile(IO.scala:580)
at sbt.IO$.sbt$IO$$copyImpl(IO.scala:559)
at sbt.IO$$anonfun$copy$1.apply(IO.scala:548)
at sbt.IO$$anonfun$copy$1.apply(IO.scala:548)
at scala.Function$$anonfun$tupled$1.apply(Function.scala:77)
at scala.Function$$anonfun$tupled$1.apply(Function.scala:76)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at sbt.IO$.copy(IO.scala:548)
at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:162)
at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:76)
at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:35)
at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:34)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
[error] (compile:compile) java.lang.IllegalArgumentException: requirement failed: Source file 'C:\Server\AuthWebManager\trunk\target\scala-2.11\classes\Routes$$anonfun$routes$1$$anonfun$applyOrElse$4.
class' does not exist.
[error] application -
! @6k3l90dc5 - Internal server error, for (GET) [/] ->
play.PlayExceptions$UnexpectedException: Unexpected exception[IllegalArgumentException: requirement failed: Source file 'C:\Server\AuthWebManager\trunk\target\scala-2.11\classes\Routes$$anonfun$routes
$1$$anonfun$applyOrElse$4.class' does not exist.]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:237) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:230) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
at play.PlayReloader$$anon$1.play$PlayReloader$$anon$$taskFailureHandler(PlayReloader.scala:230) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2.apply(PlayReloader.scala:90) ~[na:na]
Caused by: java.lang.IllegalArgumentException: requirement failed: Source file 'C:\Server\trunk\target\scala-2.11\classes\Routes$$anonfun$routes$1$$anonfun$applyOrElse$4.class' does not
exist.
at scala.Predef$.require(Predef.scala:233) ~[scala-library-2.11.1.jar:na]
at sbt.IO$.copyFile(IO.scala:580) ~[na:na]
at sbt.IO$.sbt$IO$$copyImpl(IO.scala:559) ~[na:na]
at sbt.IO$$anonfun$copy$1.apply(IO.scala:548) ~[na:na]
at sbt.IO$$anonfun$copy$1.apply(IO.scala:548) ~[na:na]
[warn] play - No application found at invoker init
我也遇到了一些不同的错误,但为了简明起见,我不会在这里写出来。我已经尝试过删除.sbt和.ivy2 / cache文件夹的建议,但这还没有解决问题。
那么我该怎么做才能使我的播放应用程序编译并运行而没有看似非确定性的错误?
答案 0 :(得分:4)
我遇到了类似的问题。我正在使用eclipse与activator。当它试图在同一个导演中构建应用程序时,看起来问题就是eclipse。我禁用了#34;自动构建"从日食开始,到目前为止工作正常。看看这个帖子:
https://groups.google.com/forum/#!topic/play-framework/4RnbqEk-muM
答案 1 :(得分:2)
之前我遇到类似的随机错误。 我已将其缩小到大量内存使用,因为完全相同的代码将在我们用于预测试调试的远程开发服务器上正常编译,如果我关闭打开的应用程序,它也会编译得很好并且没有随机错误为了保持足够的可用内存,编译器可以完成它的工作。
答案 2 :(得分:-1)
删除"目标"文件夹并再次运行,这对我有用:)!
参考文献: https://groups.google.com/forum/#!topic/play-framework/915-PGT8Zgs