Search code examples
grailsjetty

Minimal steps to allow a Grails 4 application to run under Jetty (9+)?


What are the minimum changes required to a blank-slate Grails 4 application, for it to successfully run under Jetty 9+ as a .war archive?

If I do a naive deployment of a .war, it shows up as static content (a directory listing) under Jetty. Perhaps this is something to do with a missing web.xml, which Grails hasn't used for some time?

Put another way: how do I bridge the gap between modern Grails and what Jetty is expecting?


Solution

  • In order to run Grails web application WAR with Jetty, please update the following dependency as:

    // compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.springframework.boot:spring-boot-starter-jetty"
    

    Also, you may need to also update the Jetty version via SpringBoot BOM as:

    ext['jetty.version'] = 9.4.36.v20210114
    

    Here is an example Grails 4 application which uses Jetty instead of Tomcat.