【问题标题】:Java web application blank page on heroku but runs locallyHeroku 上的 Java Web 应用程序空白页,但在本地运行
【发布时间】:2016-11-03 19:54:15
【问题描述】:

我的网络应用程序 (spark java) 在本地运行良好,但一旦部署到 Heroku 就会给我一个空白页面。

    https://fathomless-garden-15009.herokuapp.com/fathomless-garden-15009

这是日志

2016-11-03T01:54:56.324006+00:00 heroku[web.1]: State changed from crashed to starting
2016-11-03T01:55:02.989594+00:00 heroku[web.1]: Starting process with command `   java -Dserver.port=34284 -jar build/libs/freebid-0.1.0-SNAPSHOT.jar`
2016-11-03T01:55:04.872996+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS     defaults based on dyno size. Custom settings will override them.
2016-11-03T01:55:04.876437+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2016-11-03T01:55:04.970619+00:00 app[web.1]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2016-11-03T01:55:04.970667+00:00 app[web.1]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2016-11-03T01:55:04.970721+00:00 app[web.1]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2016-11-03T01:55:05.604913+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.604 [main] BuildInfo - Git commit is null 
2016-11-03T01:55:05.604806+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.603 [main] BuildInfo - Built on null by null 
2016-11-03T01:55:05.605942+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.605 [main] PropertyResolver - properties file /credentials.properties is missing or invalid
2016-11-03T01:55:05.605760+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.605 [main] PropertyResolver - properties file /environment-ex.properties is missing or invalid
2016-11-03T01:55:05.606112+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.606 [main] PropertyResolver - properties file /credentials-ex.properties is missing or invalid
2016-11-03T01:55:05.606259+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.606 [main] PropertyResolver - resolved devMode in environment.properties as true
2016-11-03T01:55:05.614766+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.614 [main] PropertyResolver - resolved httpServer.port in environment.properties as 3016
2016-11-03T01:55:05.614940+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.614 [main] PropertyResolver - resolved template.engine in environment.properties as reloadable
2016-11-03T01:55:05.705113+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.704 [main] PropertyResolver - failed to resolve heap.analytics.id
2016-11-03T01:55:05.731095+00:00 app[web.1]: [INFO ] 2016-11-03 01:55:05.730 [main] ApiController - Loading ObjectMapper
2016-11-03T01:56:33.511375+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2016-11-03T01:56:33.511626+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-11-03T01:56:33.669397+00:00 heroku[web.1]: State changed from starting to crashed
2016-11-03T01:56:33.648115+00:00 heroku[web.1]: Process exited with status 137

我的档案

web: java -Dserver.port=$PORT -jar build/libs/freebid-0.1.0-SNAPSHOT.jar

在日志中,这看起来像是罪魁祸首

Web process failed to bind to $PORT within 90 seconds of launch
2016-11-03T01:56:33.511626+00:00 heroku[web.1]: Stopping process with SIGKILL

但从 SO 上的其他解决方案表明我应该将以下内容添加到我所做的 procfile 中;

-Dserver.port=$PORT  

我不确定这是否是唯一的问题,但这将是一个开始。

非常感谢您的指点

【问题讨论】:

    标签: java heroku spark-java


    【解决方案1】:

    我不知道 Spark 是否支持 -Dserver.port 选项。我已经在 J​​ava 代码中明确设置了端口:

    port(Integer.valueOf(System.getenv("PORT")));
    

    你可以看到full example on Github

    您可以通过运行heroku local web 在本地对其进行测试,它应该绑定到端口 5000。如果没有,那么它将无法在 Heroku 上运行。

    【讨论】:

      猜你喜欢
      • 2016-06-19
      • 2020-12-10
      • 2020-07-17
      • 2014-10-24
      • 2020-11-30
      • 2014-07-29
      • 2019-05-24
      • 1970-01-01
      • 2016-12-30
      相关资源
      最近更新 更多