Ahead of Time compilation support
Table of Contents
Tomcat supports using the GraalVM/Mandrel Native Image tool to produce a native binary including the container. This documentation page describes the build process of such an image.
The native image tool is much easier to use with single JARs, as a result the process will use the Maven shade plugin JAR packaging (fat JAR). The idea is to produce a single JAR that contains all necessary classes from Tomcat, the webapps and all additional dependencies. Although Tomcat has received compatibility fixes to support native images, any library may not be compatible and may require replacement code (the GraalVM documentation has more details about this).
Download and install GraalVM or Mandrel.
If using GraalVM, the first step is then to add the Native Image tool.
export JAVA_HOME=/absolute...path...to/graalvm-ce-javaX-x.y.z cd $JAVA_HOME/bin ./gu install native-image
Download the Tomcat Stuffed module from
https://github.com/apache/tomcat/tree/main/modules/stuffed and place
all the files in a folder
stuffed in this documentation.
Packaging and Building
Inside the tomcat-stuffed folder, the directory structure is