Java Webapp部署到Heroku-错误>错误R10(启动超时)

时间:2019-04-22 18:11:24

标签: java heroku jersey jetty

将Web应用程序部署到Heroku平台时遇到问题,因为我无法对Web应用程序进行REST调用。
我查看了日志,返回了以下内容:

2019-04-22T17:58:53.942100+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-04-22T17:58:53.942570+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-04-22T17:58:54.082855+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-22T17:58:54.062137+00:00 heroku[web.1]: Process exited with status 137

我已经对此错误进行了一些研究,并实施了不同的解决方案(installed application flow)来解决此问题,但无法解决。我已经看到一些解决方案,说明要实现将0.0.0.0用作主机,但是在我的代码中,我没有使用任何主机,也不知道如果可以的话在哪里实现。

Main.java

public static void main(String[] args) throws Exception{
        // The port that we should run on can be set into an environment variable
        // Look for that variable and default to 8080 if it isn't there.
        String webPort = System.getenv("PORT");
        if (webPort == null || webPort.isEmpty()) {
            webPort = "8080";
        }

        System.out.println("Webport in use: " + webPort);

        final Server server = new Server(Integer.valueOf(webPort));
        final WebAppContext root = new WebAppContext();

        root.setContextPath("/");
        // Parent loader priority is a class loader setting that Jetty accepts.
        // By default Jetty will behave like most web containers in that it will
        // allow your application to replace non-server libraries that are part of the
        // container. Setting parent loader priority to true changes this behavior.
        // Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
        root.setParentLoaderPriority(true);

        final String webappDirLocation = "src/main/webapp/";
        root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
        root.setResourceBase(webappDirLocation);

        server.setHandler(root);

        server.start();
        server.join();
    }

Procfile-

web: java $JAVA_OPTS -Dserver.port=$PORT -cp target/classes:target/dependency/* com.example.heroku.Main

也在日志中找到了这个

2019-04-22T17:57:23.846721+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=48973 -cp target/classes:target/dependency/* com.example.heroku.Main`

我一直在关注one of the resolutions
任何帮助表示赞赏。

0 个答案:

没有答案