'Spring Boot 2 web application not starting in Tomcat 9

I have an application that is currently built on Spring Boot 1.5.9 and I am trying to update it to the latest Spring Boot 2 version.

The application uses spring-security, spring-security-taglibs, spring-boot-starter-data-jpa, spring-session-jdbc, jstl (jsp pages) and connects to two databases, I also use profiles to configure the application differently in development and production environments.

I was successfully able to upgrade my development application. I only needed to modify my pom.xml and a few java files.

During development I usually use the integrated Tomcat server. i.e. The one you get when you run mvn spring-boot:run

As a sanity test I also installed Tomcat 9.0.43 (this is the same build that is used in my production environment). The Spring Boot 2 version of the application works perfectly fine using this method.

However, all my problems started when I tried to deploy my application into the production environment.

When restarting the Tomcat server, I don't see any indication that it even detects the Spring Boot 2 application. In Spring Boot 1, I would usually get the Spring logo and a bunch of startup messages. Visiting the website in a browser shows The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

The Spring Boot application does not generate any log files and Tomcat's log files merely indicate the application was deployed successfully.

What could be causing this issue.

  • Both my development system and the production server have JRE and JDK 8 installed (although, different minor versions)
  • Both systems are running the same version of Tomcat.
  • Both systems run on Windows. The server runs on Windows server 2013 and the development environment is on Windows 10.
  • I use Visual Studio Code for development and debugging

Update 1

The spring boot 2 version of my application is using version 2.5.1 Here are a few things that I have done:

  • I have made sure that the application extends SpringBootServletInitializer
  • I can't put my local Tomcat installation in the production server (at least, not without a lot of issues), but I've copied the server's Tomcat installation onto my development machine and verified that the application DOES start correctly.
  • The only property in my POM is <java.version>8</java.version>
  • While both environment have JRE and JDK 8, they may have different minor versions

Update 2

I created a brand new Spring Boot 2.5.9 application (using Spring Initializr and no dependencies) and tried to run this in a Tomcat 8.5.20 instance on the server. I also created an index.html to display a simple Hello World!!! if the application starts correctly

  • The application works fine on my development system (using both integrated Tomcat and separate Tomcat installation)
  • In production, the Spring Boot application did not start (i.e. I got a 404)
  • It did not appear to generate any logs or errors.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source