我在生产中运行我的应用程序时遇到了有关访问资产的错误(在开发过程中正常运行):
[info] play.api.Play - Application started (Prod)
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
[error] application -
! @784kabl4n - Internal server error, for (GET) [/assets/images/favicon.png] ->
play.api.UnexpectedException: Unexpected exception[RuntimeException: java.lang.IllegalAccessError: class play.utils.Resources$ (in unnamed module @0x67dd1848) cannot access class sun.net.www.protocol.file.FileURLConnection (in module java.base) because module java.base does not export sun.net.www.protocol.file to unnamed module @0x67dd1848]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:251)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:182)
at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:343)
at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:341)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:414)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessError: class play.utils.Resources$ (in unnamed module @0x67dd1848) cannot access class sun.net.www.protocol.file.FileURLConnection (in module java.base) because module java.base does not export sun.net.www.protocol.file to unnamed module @0x67dd1848
at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:424)
at play.api.mvc.Action.$anonfun$apply$2(Action.scala:96)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$4(Accumulator.scala:174)
at scala.util.Try$.apply(Try.scala:209)
at play.api.libs.streams.StrictAccumulator.$anonfun$mapFuture$3(Accumulator.scala:174)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:207)
at play.core.server.AkkaHttpServer.$anonfun$runAction$4(AkkaHttpServer.scala:337)
Caused by: java.lang.IllegalAccessError: class play.utils.Resources$ (in unnamed module @0x67dd1848) cannot access class sun.net.www.protocol.file.FileURLConnection (in module java.base) because module java.base does not export sun.net.www.protocol.file to unnamed module @0x67dd1848
at play.utils.Resources$.isUrlConnectionADirectory(Resources.scala:32)
at controllers.AssetsBuilder.$anonfun$assetAt$3(Assets.scala:817)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:304)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:70)
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
at scala.concurrent.impl.Promise$DefaultPromise.dispatchOrAddCallback(Promise.scala:312)
at scala.concurrent.impl.Promise$DefaultPromise.onComplete(Promise.scala:303)
at scala.concurrent.impl.Promise.transformWith(Promise.scala:36)
我可以通过http / https访问应用程序本身,而Nginx充当代理,但似乎Play应用程序本身无法获取资产。
关于资产的route
是:
GET /assets/*file controllers.Assets.versioned(file)
并且在views
我有:
<head>
<link rel="shortcut icon" type="image/png" href="@assetsFinder.path("images/favicon.png")">
</head>
知道如何调试这个吗?
答案 0 :(得分:0)
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
然后我可以用它
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.ico")">
我是根据https://www.playframework.com/documentation/2.6.x/AssetsOverview#reverse-routing-for-public-assets中的示例做到的,并且没有遇到任何问题。
仔细检查您的权限,但我不认为权限与错误有关:(
也许您也可以在gitter channel或discuss
中发布问题答案 1 :(得分:0)