M Heilner
M Heilner

Reputation: 33

Can a Grails 3 Server be deployed on Tomcat 10?

I am able to deploy my Grails 3 Server on Tomcat 8.5.x and Tomcat 9 (running Java8). I can't seem to get it working on Tomcat 10. I'm wondering if it's even possible. Is there a version matrix with Grails, Tomcat, and Java that someone can point me to?

Upvotes: 3

Views: 1318

Answers (1)

rchfox
rchfox

Reputation: 197

There is no easy answer to your question.

Grails compatibility with Tomcat depends on Tomcat and Java compatibility, and Grails compatibility with Java in turns depends on Groovy compatibility with Java and also on Spring/SpringBoot compatibility with Java.

Unfortunately, details about this matter tends to be scant, if any, in Grails official documentation.

So let's start putting the pieces together...

Grails - Groovy

To even find out which version of Groovy comes with which version of Grails, sometimes you will have to inspect the Grails package, because that information is not always present in Grails Documentation for every version.

The lib folder in every Grails package includes the Groovy version it depends on. This is from my computer (I have installed 8 different versions of Grails for different projects):

grails/2.2.0/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.0.5.jar
grails/2.3.2/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar
grails/2.3.6/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar
grails/2.4.3/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.3.6.jar
grails/2.5.6/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.4.10.jar
grails/3.3.14/lib/org.codehaus.groovy/groovy/jars/groovy-2.4.21.jar
grails/4.0.12/lib/org.codehaus.groovy/groovy/jars/groovy-2.5.14.jar
grails/4.1.0.M5/lib/org.codehaus.groovy/groovy/jars/groovy-3.0.7.jar

Someone even went to the trouble of compiling and sharing data about the specific version of Groovy included in every version of Grails.

And this is my own summary:

GRAILS   Groovy
version  version   
-------  -------  
2.0.x    1.8.x      
2.1.x    1.8.x  
2.2.x    2.0.x      
2.3.x    2.1.x      
2.4.x    2.3.x      
2.5.x    2.4.x   
3.x.x    2.4.x
4.0.x    2.5.x
4.1.x    3.0.x

Please note that Grails has been very conservative about its Groovy version transitions. Also note that, as for today (2021-09-28), only beta versions of Grails (namely Grails 4.1.x) supports Groovy 3.x.

Grails - Spring/Spring Boot

Grails dependency on Spring and Spring Boot versions is available in Grails Documentation.

For example, Grails 3.3.14 uses Spring Framework 4.3.9 and Spring Boot 1.5.4. Both of them, Spring 4.3.9 Documentation and Spring Boot 1.5.4 Documentation, recommend Java 8, but also are backward compatible with Java 6 and Java 7.

Again, the lib folder in every Grails package includes the Spring / Spring Boot version it depends on. This is from my computer:

grails/2.2.0/lib/org.springframework/spring-core/jars/spring-core-3.1.2.RELEASE.jar
grails/2.3.2/lib/org.springframework/spring-core/jars/spring-core-3.2.4.RELEASE.jar
grails/2.3.6/lib/org.springframework/spring-core/jars/spring-core-3.2.7.RELEASE.jar
grails/2.4.3/lib/org.springframework/spring-core/jars/spring-core-4.0.6.RELEASE.jar
grails/2.5.6/lib/org.springframework/spring-core/jars/spring-core-4.1.9.RELEASE.jar
grails/3.3.14/lib/org.springframework/spring-core/jars/spring-core-4.3.25.RELEASE.jar
grails/3.3.14/lib/org.springframework.boot/spring-boot/jars/spring-boot-1.5.22.RELEASE.jar
grails/4.0.12/lib/org.springframework/spring-core/jars/spring-core-5.2.3.RELEASE.jar
grails/4.0.12/lib/org.springframework/spring-core/jars/spring-core-5.1.19.RELEASE.jar
grails/4.0.12/lib/org.springframework.boot/spring-boot/jars/spring-boot-2.1.18.RELEASE.jar
grails/4.1.0.M5/lib/org.springframework/spring-core/jars/spring-core-5.3.2.jar
grails/4.1.0.M5/lib/org.springframework.boot/spring-boot/jars/spring-boot-2.4.1.jar

Fortunately, support of Spring and Spring Boot for Java is well documented for every release.

This is my summary:

         Spring     Spring   Supported
GRAILS   Framework  Boot     Java version
-------  ---------  -------  -------------  
2.2.x    3.1.x      N/A      up to 6
2.3.x    3.2.x      N/A      up to 7
2.4.x    4.0.x      N/A      up to 8
2.5.x    4.1.x      N/A      up to 8
3.0.x    4.1.x      1.2.x    up to 8
3.1.x    4.2.x      1.3.x    up to 8
3.2.x    4.3.x      1.4.x    up to 8
3.3.x    4.3.x      1.5.x    up to 8
4.0.x    5.1.x      2.1.x    up to 11
4.1.x    5.3.x      2.4.x    up to 11

Tomcat - Java

Tomcat has its own compatibility matrix with different Java versions. There you can see that starting 10.1.x Tomcat supports Java 11 and later, but version 10.0.x still supports Java 8.

Groovy - Java

Regarding Groovy compatibility with Java, you will find specific information in the Groovy's Release Notes files. For instance, according to the release notes, Groovy has official support for running on JDK 8 staring Groovy 2.3.

Also according the release notes, apparently Groovy 2.5.x works also with JDK 9/10 and JDK 11, although it has some caveats and instructions for each one; and better support for Java >= 9 were introduced in Groovy 3.0.

This is my summary:

                    Supported
GRAILS   Groovy     Java version(*)
-------  ---------  -------------  
2.0.x    1.8.x      up to 6      
2.1.x    1.8.x      up to 6  
2.2.x    2.0.x      up to 6      
2.3.x    2.1.x      up to 7      
2.4.x    2.3.x      up to 8      
2.5.x    2.4.x      up to 8   
3.x.x    2.4.x      up to 8
4.0.x    2.5.x      up to 9/10/11(**)
4.1.x    3.0.x      up to 11+

(*)  Supported Java versions is based just on 
     my understanding of the release notes  

(**) There are some caviats in the release notes

Solving the puzzle

Now we have the pieces to solve this puzzle for any specific Grails and Tomcat versions combination.

For example:

  • Grails 2.4.0 bundles Groovy 2.3 and Spring 4.0
  • Groovy >= 2.3 has official support for JDK 8
  • Spring 4.0.x supports up to Java 8
  • Hence Grails 2.4.0 supports Java 8
  • Tomcat 9.0.x and 10.0.x supports Java 8 and later
  • Therefore you can run Grails 2.4.0 on Tomcat 9.0.x and 10.0.x

In your particular case, lets say that you have the latest version of Grails 3.x series: Grails 3.3.14:

  • Grails 3.3.14 bundles Groovy 2.4.21 and Spring 4.3.25
  • Groovy 2.4.x supports Java 8, but still lacks enough support for newer Java versions
  • Spring 4.3.25 supports up to Java 8
  • Hence Grails 3.3.14 supports Java 8, and probably won't work on Java 11
  • Tomcat 9.0.x and 10.0.x supports Java 8 and later
  • Therefore you can run Grails 3.3.14 on Tomcat 9.0.x and 10.0.x, but not on Tomcat >= 10.1.x which requires Java 11 or later

Summary Chart

+---------+---------+-----------+---------+----------------+-------------+
|         |      Bundled with GRAILS      | Max version of |             |
|         +---------+-----------+---------+ Java supported | Max version |
|         |         | Spring    | Spring  | by GRAILS with | of Tomcat   |
| GRAILS  | Groovy  | Framework | Boot    | bundled Spring | compatible  |
| version | version | version   | version | and Groovy (*) | with GRAILS |
+---------+---------+-----------+---------+----------------+-------------+
|  2.0.x  |  1.8.x  |   3.1.x   |  N/A    |                |             |
|  2.1.x  |  1.8.x  |   3.1.x   |  N/A    |  up to 6       |      7.0.x  |
|  2.2.x  |  2.0.x  |   3.1.x   |  N/A    |                |             |
+---------+---------+-----------+---------+----------------+-------------+
|  2.3.x  |  2.1.x  |   3.2.x   |  N/A    |  up to 7       |      8.5.x  |
+---------+---------+-----------+---------+----------------+-------------+
|  2.4.x  |  2.3.x  |   4.0.x   |  N/A    |                |             |
|  2.5.x  |  2.4.x  |   4.1.x   |  N/A    |                |      9.0.x  |
|  3.0.x  |  2.4.x  |   4.1.x   |  1.2.x  |  up to 8       |        and  |
|  3.1.x  |  2.4.x  |   4.2.x   |  1.3.x  |                |     10.0.x  |
|  3.2.x  |  2.4.x  |   4.3.x   |  1.4.x  |                |             |
|  3.3.x  |  2.4.x  |   4.3.x   |  1.5.x  |                |             |
+---------+---------+-----------+---------+----------------+-------------+
|  4.0.x  |  2.5.x  |   5.1.x   |  2.1.x  |  up to 11 (**) |     10.1.x  |
+---------+---------+-----------+---------+----------------+-------------+
|  4.1.x  |  3.0.x  |   5.3.x   |  2.4.x  |  up to 11+     |     10.1.x  |
+---------+---------+-----------+---------+----------------+-------------+
 Last Updated: 2021-09-29

(*)  Supported Java versions is based just on my own understanding 
     of Groovy and Spring release notes

(**) There are some caviats for JDK 9/10/11 in the release notes 
     of Groovy 2.5.x

Upvotes: 13

Related Questions