Spring: 404 errors on AWS Elastic Beanstalk (Tomcat)

I had run into a strange issue while trying to deploy a simple “Hello World” application on AWS Elastic Beanstalk. I had gone through all the guides available, set SERVER_PORT to 5000, made sure my main class was extending SpringBootServletInitializer and so on…

My application ran fine locally, I could see “Hello World” in my browser.

While looking at the Beanstalk dashboard, I noticed that it tells me the version of Tomcat and Java: Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.2.2

Okay, so Elastic Beanstalk uses these Java versions… so I checked my pom.xml file, and noticed…

...
<java.version>11</java.version>
...

I changed it to 1.8 (Java versioning is weird and inconsistent… 1.8 is Java 8)

I then ran mvn clean package and re-uploaded my war file… and boom, “Hello World” appeared in my browser…

What’s funny is, I didn’t see anything in the Beanstalk logs indicating this was the problem! I just gave it a shot and it fixed the issue.