运行 Heroku 上的 Grails 3

Running Grails 3 on Heroku

我正在尝试在 Heroku 上部署最简单的 Grails 3 应用程序,但没有成功。

Heroku doc only provides information to deploy a Grails 2 app. So I have followed that blog article 解释了如何部署 Grails 3 应用程序。但它会导致以下异常:

2015-06-09T21:03:41.637499+00:00 app[web.1]:   .   ____          _            __ _ _
2015-06-09T21:03:41.637570+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2015-06-09T21:03:41.637651+00:00 app[web.1]:   '  |____| .__|_| |_|_| |_\__, | / / / /
2015-06-09T21:03:41.637612+00:00 app[web.1]:  \/  ___)| |_)| | | | | || (_| |  ) ) ) )
2015-06-09T21:03:41.637693+00:00 app[web.1]:  =========|_|==============|___/=/_/_/_/
2015-06-09T21:03:41.641123+00:00 app[web.1]: 
2015-06-09T21:03:41.641085+00:00 app[web.1]:  :: Spring Boot ::        (v1.2.3.RELEASE)
2015-06-09T21:04:03.066389+00:00 app[web.1]: ERROR org.apache.catalina.core.ContainerBase - A child container failed during start
2015-06-09T21:04:03.066397+00:00 app[web.1]: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
2015-06-09T21:04:03.066399+00:00 app[web.1]:    at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066401+00:00 app[web.1]:    at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066403+00:00 app[web.1]:    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) ~[webapp-runner.jar:na]
2015-06-09T21:04:03.066404+00:00 app[web.1]:    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800) [webapp-runner.jar:na]
2015-06-09T21:04:03.066406+00:00 app[web.1]:    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [webapp-runner.jar:na]
2015-06-09T21:04:03.066408+00:00 app[web.1]:    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [webapp-runner.jar:na]
2015-06-09T21:04:03.066409+00:00 app[web.1]:    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [webapp-runner.jar:na]
2015-06-09T21:04:03.066411+00:00 app[web.1]:    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066413+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066414+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066417+00:00 app[web.1]:    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40-'cedar14']
2015-06-09T21:04:03.066419+00:00 app[web.1]: Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
2015-06-09T21:04:03.066420+00:00 app[web.1]:    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [webapp-runner.jar:na]
2015-06-09T21:04:03.066422+00:00 app[web.1]:    ... 6 common frames omitted
2015-06-09T21:04:03.066424+00:00 app[web.1]: Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
2015-06-09T21:04:03.066425+00:00 app[web.1]:    at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
2015-06-09T21:04:03.066427+00:00 app[web.1]:    at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
2015-06-09T21:04:03.066429+00:00 app[web.1]:    at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47) ~[tomcat-embed-websocket-8.0.20.jar:8.0.20]
2015-06-09T21:04:03.066431+00:00 app[web.1]:    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5274) ~[webapp-runner.jar:na]
2015-06-09T21:04:03.066432+00:00 app[web.1]:    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [webapp-runner.jar:na]
2015-06-09T21:04:03.066434+00:00 app[web.1]:    ... 6 common frames omitted

有没有人在 Heroku 上成功部署 Grails 3 应用程序?循序渐进的方法是无价的。

虽然我不是 Grails 专家,但在我看来这像是 servlet API jar 的版本冲突。方法 ServletContext.getVirtualServerName 仅在 servlet API 3.1 之后可用,但看起来这个 jar 的旧版本在类路径中并且隐藏了可能由 Tomcat 提供的版本。尝试从类路径中删除对 servlet-api.jar 的显式引用,或者将其范围设置为 "provided"(如果适用)。

  1. 您似乎有一个想要使用网络套接字的依赖项。该依赖项需要一个嵌入式 tomcat 8 websocket 库。在博客中下载的 web app runner jar 是 tomcat 7 也许可以尝试下载 8.0.18
  2. 的 M1 版本

http://search.maven.org/#artifactdetails%7Ccom.github.jsimone%7Cwebapp-runner%7C8.0.18.0-M1%7Cjar


  1. Global dataSource 属性 导致 Postgres 驱动程序加载失败。删除 grails-app/conf/application.yml 中的以下行:

    -dataSource:
    -    pooled: true
    -    jmxExport: true
    -    driverClassName: org.h2.Driver
    -    username: sa
    -    password:
    

公关:https://github.com/davydotcom/grails3-on-heroku/commit/8593e846efbd79804d9013db1b8b8f0e73cf9629