Running Grails 3 on Heroku

591 Views Asked by At

I am trying to deploy the most simple possible Grails 3 app on Heroku, without success.

The Heroku doc only provides information to deploy a Grails 2 app. So I have followed that blog article which explains how to deploy a Grails 3 app. But it leads to the following exception:

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

Did anyone succeed at deploying a Grails 3 app on Heroku? A step by step method would be priceless.

2

There are 2 best solutions below

2
On BEST ANSWER
  1. It appears you have a dependency that wants to use web sockets. The dependency is requiring an embedded tomcat 8 websocket library. The web app runner jar downloaded in the blog is tomcat 7 maybe try downloading the M1 release for 8.0.18

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


  1. Global dataSource property is causing Postgres driver to fail to load. Remove the following lines in grails-app/conf/application.yml:

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

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

0
On

Although I'm not a Grails expert, this looks to me like a version conflict of the servlet API jar. The method ServletContext.getVirtualServerName is only available since servlet API 3.1, but it looks like an older version of this jar is on the classpath and hides the one probably prpvided by Tomcat. Try either to remove an explicit reference to servlet-api.jar from the classpath or to set its scope to "provided" (if applicable).