Deploying Spring Boot 2.x war in Tomcat 10

In this blog , I will discuss step by step process to deploy Spring Boot 2.x based war files in Tomcat 10 web server.

The main reason, why you can not deploy Spring Boot 2.x based web application in Tomcat 10 is Spring Boot 2.x and Tomcat 9 are based on Java EE8 specification but Tomcat 10 is based on Jakarta EE 9 specification.

Differences between Java EE 8 and Jakarta EE 9

The difference between Java EE 8 and Jakarta EE 9 is that all the Java EE 8 packages in the javax.* namespace have moved to the jakarta.* namespace. Some sub-packages have also been renamed.

If we need to deploy web applications based on Java EE 8 on Tomcat 10 , we need to to refactor the all the application code so that it confirms to Jakarta EE 9.Doing migrations is manually is practically impossible. So Apache has developed a migration tool which performs all the necessary changes to migrate an application from Java EE 8 to Jakarta EE 9 by renaming each Java EE 8 package to its Jakarta EE 9 replacement. This includes package references in classes, String constants, configuration files, JSPs, TLDs etc.

Step 1: Build the war file that is compatible with tomcat 9.

mvn clean package
Code language: Java (java)

Step 2: Migrating war file

First download the migration jar from

Copy the jar file to target folder of the project

Run the following command to migrate the war file

java -jar jakartaee-migration-*-shaded.jar <source>.war <destination>.war
Code language: Java (java)

In real-time projects deployments, it is not possible to run the migration step manually.

Now let’s look at the automated process to migrate the war file after building the package.

Automating the Migration from Java EE 8 to Jakarta EE 9

I am going to use maven-dependency-plugin , exec-maven-plugin plugs to to automate the migration process.

maven-dependency-plugin – Used to copy the migration jar

exec-maven-plugin – Used for running the migration command.

Step 1) Add the migration dependency in the pom.xml

<dependency> <groupId>org.apache.tomcat</groupId> <artifactId>jakartaee-migration</artifactId> <version>1.0.4</version> <classifier>shaded</classifier> <scope>compile</scope> </dependency>
Code language: Java (java)

Step 2) Configure the maven-dependency-plugin plugin to copy the migration jar to to target folder.

<build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-resources</id> <phase>package</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.apache.tomcat</groupId> <artifactId>jakartaee-migration</artifactId> <version>1.0.4</version> <type>jar</type> <classifier>shaded</classifier> <outputDirectory>${}</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> .... </plugins> </build>
Code language: Java (java)

Step 3) Configure the exec-maven-plugin plugin to run the migration command.

<build> <plugins> ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>up</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>java</executable> <workingDirectory>${}</workingDirectory> <arguments> <argument>-jar</argument> <argument>jakartaee-migration-1.0.4-shaded.jar</argument> <argument>sb-war-docker-0.0.1-SNAPSHOT.war</argument> <argument>sb-war-docker.war</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build>
Code language: Java (java)

Step 4) Run the maven package command to produce migrated war file

mvn clean package
Code language: Java (java)

When run the above command , you will get migrated war file in your target folder which can be deployed in Tomcat 10 webserver.

You can download source code for the blog post from GitHub

Similar Posts