【问题标题】:Java Web App Crashing on HerokuJava Web App 在 Heroku 上崩溃
【发布时间】:2015-07-13 04:15:51
【问题描述】:

我有一个现有的 Java Web 应用程序项目。我将其转换为一个 Maven 项目并将其部署在 Heroku 上。应用部署成功但没有运行;它崩溃了。我无法从日志中找出原因。我的 Procfile 看起来像这样: 网络:java $JAVA_OPTS -cp target/classes:target/m2e-wtp/*.jar

我在日志中看到的只是应用程序崩溃,错误代码 = H10,状态为 503。我非常感谢有关此方面的帮助。以下是日志:

app[web.1]: See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: Process exited with status 1
heroku[api]: Scale to web=1 by charan7j86@gmail.com
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fierce-woodland-8040.herokuapp.com request_id=9e462e2f-0e4f-4ef7-a503-e557fa46397a fwd="67.169.27.222" dyno= connect= service= status=503 bytes=
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fierce-woodland-8040.herokuapp.com request_id=fcfb168d-3c62-4c0b-92ba-0a0418cdc703 fwd="67.169.27.222" dyno= connect= service= status=503 bytes=
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `java -XX:+UseCompressedOops -cp target/classes:target/m2e-wtp/*.jar`
app[web.1]: Usage: java [-options] class [args...]
app[web.1]:            (to execute a class)
app[web.1]:    or  java [-options] -jar jarfile [args...]
app[web.1]:            (to execute a jar file)
app[web.1]: where options include:
app[web.1]:     -d32      use a 32-bit data model if available
app[web.1]:     -d64      use a 64-bit data model if available
app[web.1]:                   The default VM is server,
app[web.1]:     -server      to select the "server" VM
app[web.1]:                   because you are running on a server-class machine.
app[web.1]: 
app[web.1]:     -cp <class search path of directories and zip/jar files>
app[web.1]: 
app[web.1]:     -classpath <class search path of directories and zip/jar files>
app[web.1]:                   A : separated list of directories, JAR archives,
app[web.1]:                   and ZIP archives to search for class files.
app[web.1]:     -D<name>=<value>
app[web.1]:                   set a system property
app[web.1]:     -verbose:[class|gc|jni]
app[web.1]:                   enable verbose output
app[web.1]:     -version      print product version and exit
app[web.1]:     -version:<value>
app[web.1]:                   require the specified version to run
app[web.1]:     -showversion  print product version and continue
app[web.1]:     -jre-restrict-search | -no-jre-restrict-search
app[web.1]:                   include/exclude user private JREs in the version search
app[web.1]:     -? -help      print this help message
app[web.1]:     -X            print help on non-standard options
app[web.1]:     -ea[:<packagename>...|:<classname>]
app[web.1]:     -enableassertions[:<packagename>...|:<classname>]
app[web.1]:                   enable assertions with specified granularity
app[web.1]:     -disableassertions[:<packagename>...|:<classname>]
app[web.1]:     -da[:<packagename>...|:<classname>]
app[web.1]:     -esa | -enablesystemassertions
app[web.1]:                   disable assertions with specified granularity
app[web.1]:                   enable system assertions
app[web.1]:     -dsa | -disablesystemassertions
app[web.1]:                   disable system assertions
app[web.1]:     -agentlib:<libname>[=<options>]
app[web.1]:                   load native agent library <libname>, e.g. -agentlib:hprof
app[web.1]:                   see also, -agentlib:jdwp=help and -agentlib:hprof=help
app[web.1]:     -agentpath:<pathname>[=<options>]
app[web.1]:                   load native agent library by full pathname
app[web.1]:     -javaagent:<jarpath>[=<options>]
app[web.1]:                   load Java programming language agent, see java.lang.instrument
app[web.1]:     -splash:<imagepath>
app[web.1]:                   show splash screen with specified image
app[web.1]: See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed

【问题讨论】:

  • 您能否给我们看一些日志,以便我们看看是否还有其他内容?请清除日志并运行一次并将日志添加到问题中。
  • 请看帖子中的日志

标签: java maven heroku


【解决方案1】:

Procfile 中的命令未指定 Main 类。它应该看起来像:

 web: java $JAVA_OPTS -cp target/classes:target/m2e-wtp/*.jar com.foo.Main

【讨论】:

  • 感谢您的回答。既然是 web 应用,那么主类会是 HTML 主页的路径吗?
  • 不,它将是一个带有public static void main(String[]) 方法的Java 类。您是否正在尝试构建 WAR 文件?
  • 没有。我已经使用项目文件创建了一个本地 git 存储库,并将该存储库推送到 heroku master。它将项目检测为 java 应用程序并成功构建和部署它,但无法运行它。是java web应用,没有主类。
  • 它是可执行的 JAR 文件吗?某处必须有一个主类——这正是 Java 的工作方式。也许你需要 jetty-runner 或 webapp-runner?
  • 我能够成功运行应用程序。我创建了项目的 war 文件,在 Procfile 中指定了 HTML 主页的路径,并在 Heroku 中使用 war 命令部署了它。我正在针对旧版本的 Jre 编译我的项目,而不是在应用程序崩溃的 Heroku 上。一旦我更新了版本,它就运行了。感谢您告诉我必须在 Procfile 中指定路径!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-25
  • 2014-08-29
  • 2017-06-24
  • 2016-01-22
相关资源
最近更新 更多