1

I created on my local computer (windows) a spring-boot project that runs a tomcat server.

Code:

@RestController
    public class ServerController {
    @Autowired
    private CalculateService calculateService;

    @RequestMapping ("/demo")
    public int demo () {
      return 999;
}

I ran, and saw that "http://localhost:8080/demo" returns 999.

I packaged it to a war file - "demo-0.0.1-SNAPSHOT.war", and copied it into the "/usr/java/apache-tomcat-8.5.40/webapps/" folder, in a linux instance of a aws ec2 server.

When I run /.startup.sh, is starts with:

Using CATALINA_BASE:   /usr/java/apache-tomcat-8.5.40
Using CATALINA_HOME:   /usr/java/apache-tomcat-8.5.40
Using CATALINA_TMPDIR: /usr/java/apache-tomcat-8.5.40/temp
Using JRE_HOME:        /
Using CLASSPATH:       /usr/java/apache-tomcat- 
8.5.40/bin/bootstrap.jar:/usr/java/apache-tomcat-8.5.40/bin/tomcat-juli.jar
Tomcat started.

When i enter in my computer browser the url:

<instance url>:8080

the Apache Tomcat/8.5.40 home page loads. But when i call the demo server from the ec2:

wget http://localhost:8080/demo-0.0.1-SNAPSHOT/demo

or from outside by

<instance url>:8080/demo-0.0.1-SNAPSHOT/demo

it returns returns 404.

Deleting the default "web-apache.war" file from "webapps" folder, doesn't fix the problem.

What i need to change in the configurations?

Zag Gol
  • 1,038
  • 1
  • 18
  • 43
  • why you are adding "demo-0.0.1-SNAPSHOT" to the request URL? It should work same as in your local machine. just try wget localhost:8080/demo (from remote aws machine" – Adi Ohana Apr 21 '19 at 13:46
  • "wget localhost:8080/demo" gives a error. only "wget localhost:8080/" works (to Apache Tomcat/8.5.40 home page only) – Zag Gol Apr 21 '19 at 13:57
  • 1
    try to run the spring boot application with "java -jar" command instead of using the startup.sh script – Adi Ohana Apr 21 '19 at 13:59
  • but the demo file is a war file?! – Zag Gol Apr 21 '19 at 14:01
  • 1
    spring boot support webapplications as jar files: https://stackoverflow.com/questions/39281516/spring-boot-package-web-application-to-jar – Adi Ohana Apr 21 '19 at 14:04
  • Runs perfect! Thanks – Zag Gol Apr 21 '19 at 14:30
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/192172/discussion-between-zag-gol-and-adi-ohana). – Zag Gol Apr 21 '19 at 15:36

0 Answers0