scala - Heroku 的 Play/scala 应用停止运行

标签 scala ssl heroku playframework

在本地运行我的 heroku 应用程序时突然遇到这个问题,我的 Play/Scala 应用程序无法运行。看到这个可能导致无法加载 SSL 上下文的错误:

22:27:05 web.1   |  Caused by: com.typesafe.config.ConfigException$WrongType: system properties: path has type OBJECT rather than STRING

简介:

web: target/universal/stage/bin/myapp -Dhttps.port=${PORT} -Dhttp.port=disabled -Dhttps.keyStore.path=conf/generated.keystore

我在远程也遇到同样的错误。如果我在没有 Heroku 的情况下在本地运行应用程序,我看不到任何问题 (sbt -Dhttps.port=$1 -Dhttp.port=disabled ~run)。不清楚它指的是什么配置属性。 Play 版本 2.5.4。

完整日志:

$ heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
22:26:38 web.1   |  2017-08-17 22:26:38,177 [debug] p.a.l.c.ActorSystemProvider - Starting application default Akka system: application
22:26:39 web.1   |  2017-08-17 22:26:39,289 [debug] p.a.d.s.DefaultSlickApi - Created Slick database config for key admin.
22:26:40 web.1   |  2017-08-17 22:26:40,049 [debug] p.a.d.s.DefaultSlickApi - Created Slick database config for key default.
22:26:40 web.1   |  2017-08-17 22:26:40,276 [info] play.api.Play - Application started (Prod)
22:26:40 web.1   |  2017-08-17 22:26:40,394 [info] p.c.s.NettyServer - Listening for HTTPS on /0.0.0.0:5000
22:27:05 web.1   |  2017-08-17 22:27:05,481 [error] p.c.s.NettyServer - cannot load SSL context
22:27:05 web.1   |  java.lang.reflect.InvocationTargetException: null
22:27:05 web.1   |      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
22:27:05 web.1   |      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
22:27:05 web.1   |      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
22:27:05 web.1   |      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
22:27:05 web.1   |      at play.core.server.ssl.ServerSSLEngine$.createScalaSSLEngineProvider(ServerSSLEngine.scala:96)
22:27:05 web.1   |      at play.core.server.ssl.ServerSSLEngine$.createSSLEngineProvider(ServerSSLEngine.scala:32)
22:27:05 web.1   |      at play.core.server.NettyServer.liftedTree1$1(NettyServer.scala:91)
22:27:05 web.1   |      at play.core.server.NettyServer.play$core$server$NettyServer$$sslEngineProvider$lzycompute(NettyServer.scala:90)
22:27:05 web.1   |      at play.core.server.NettyServer.play$core$server$NettyServer$$sslEngineProvider(NettyServer.scala:89)
22:27:05 web.1   |      at play.core.server.NettyServer$$anonfun$channelSink$1.apply(NettyServer.scala:158)
22:27:05 web.1   |  Caused by: com.typesafe.config.ConfigException$WrongType: system properties: path has type OBJECT rather than STRING
22:27:05 web.1   |      at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:159)
22:27:05 web.1   |      at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
22:27:05 web.1   |      at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
22:27:05 web.1   |      at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
22:27:05 web.1   |      at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:246)
22:27:05 web.1   |      at play.core.server.ssl.DefaultSSLEngineProvider.createSSLContext(DefaultSSLEngineProvider.scala:34)
22:27:05 web.1   |      at play.core.server.ssl.DefaultSSLEngineProvider.<init>(DefaultSSLEngineProvider.scala:24)
22:27:05 web.1   |      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
22:27:05 web.1   |      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
22:27:05 web.1   |      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
22:27:05 web.1   |  2017-08-17 22:27:05,531 [debug] application - Client Error: code: 400, msg: text is empty
22:27:05 web.1   |  2017-08-17 22:27:05,531 [debug] application - Request: GET /bad-request
22:27:05 web.1   |  2017-08-17 22:27:05,533 [debug] application -     content-type: None
22:27:05 web.1   |  2017-08-17 22:27:05,533 [debug] application -     headers: ArrayBuffer()
22:27:05 web.1   |  2017-08-17 22:27:05,533 [debug] application - Request: GET /bad-request
22:27:05 web.1   |  2017-08-17 22:27:05,534 [debug] application -     query string: 

$ find . -type f -name "*.keystore"
./conf/generated.keystore
./target/scala-2.11/classes/generated.keystore
./target/universal/stage/conf/generated.keystore
$

最佳答案

关注帖子后How to configure Play! 2.4.2 HTTPS keystore? , 我将 Procfile 更改为

web: target/universal/stage/bin/myapp -Dhttps.port=${PORT} -Dhttp.port=disabled -Dhttps.keyStore=conf/generated.keystore

它克服了这个错误。也就是说,我从 https.keyStore 变量中删除了“.path”。

关于scala - Heroku 的 Play/scala 应用停止运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45749242/

相关文章:

scala - Scala 中的 Future 是一个 monad 吗?

scala 计算单词中的字母对

Scala Set.contains 没有给出预期的类型不匹配错误

ssl - 将数据发布到 HTTPS 页面

javascript - Ajax Angular SSL CORS

python - 将纯 python 部署到 heroku

git - 如何持续部署 : VisualStudio. com 的 tfs Git -> Heroku

scala - SLF4J 初始化 - 替代记录器

django - 使用 django、celery、cloudamqp 和 heroku 的 ssl

Heroku psql 列出了数百个奇怪的数据库