Skip to content
Advertisement

REST API returning http status 404 when deployed on EC2 instance on AWS

I have a simple spring boot app which has just 2 rest controllers and I am exporting the war for the same. I am deploying the same war using the tomcat manager on EC2 instance on AWS, but unfortunately I am getting http status 404 when trying to hit the API.

URL that I am trying to hit is –

[public IP shared by AWS]:[port number on which tomcat is running:8080]/[context route which is the name of my war file]/[my mapped urls]

[publicIP]:8080/aws-0.0.1-SNAPSHOT/login/code

My Controller class

JavaScript

My pom.xml

JavaScript

I tried with java version 8 as well, the tomcat version that I have on my EC2 instance is 9 (apache-tomcat-9.0.70)

I also tried getting one sample war application that tomcat shares for the testing purpose – https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/

But surprisingly, this is working fine which tells me that my tomcat and java installations don’t have any issues.

Any help would be appreciated.

Advertisement

Answer

As highlighted by @khmarbaise above, I was using spring boot 3.0.0 but I had java 8 installed on my EC2 instance and spring boot 3.0.0 requires java version 17+, and that is why I was getting 404 when hitting my APIs.

After downgrading my spring boot version to 2.7.6 I am able to get a corresponding response from the APIs.

Also, as mentioned by other comments regarding the use of “/”, omitting the slash was not an issue as the slash is an optional parameter.

Thanks

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement