Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After deployment of WAR to tomcat docker container always getting 404

Tags:

docker

tomcat

war

I have a grails app, that already runs and was deployed to AWS through Elastic Beanstalk on Tomcat8 Jre8.

I am now trying to deploy it on multi-docker environment and I have quite weird behavior.

I am using tomcat:8.0-jre8 (https://hub.docker.com/r/library/tomcat/) as an image for container, and the deployment on that image is pretty simple, by putting a war file in <tomcat_home>/webapps. Also, I am mapping port 8080 to the outside world. So, related portion of docker-compose look like this:

api:
  image: tomcat:8.0-jre8
  container_name: api
  volumes:
    - ./deployment/api:/usr/local/tomcat/webapps
  external_links:
    - mysql:mysql
  ports:
    - "8080:8080"

Based on the logs, the app is getting deployed successfully, and even liquibase migrations are getting applied:

21-Nov-2016 07:11:03.671 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/priz-0.5.war
21-Nov-2016 07:12:12.496 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2016-11-21T07:13:38.397268676Z 
Configuring Spring Security Core ...
... finished configuring Spring Security Core
2016-11-21T07:13:40.215275700Z 
2016-11-21T07:13:40.777432843Z 
Configuring Spring Security REST 2.0.0.M2...
... finished configuring Spring Security REST
2016-11-21T07:13:41.515464956Z 
INFO 11/21/16 7:14 AM: liquibase: Successfully acquired change log lock
INFO 11/21/16 7:14 AM: liquibase: Reading from priz.DATABASECHANGELOG
INFO 11/21/16 7:14 AM: liquibase: Successfully released change log lock
21-Nov-2016 07:15:09.019 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/priz-0.5.war has finished in 245,345 ms
21-Nov-2016 07:15:09.026 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
21-Nov-2016 07:15:09.036 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
21-Nov-2016 07:15:09.038 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 245425 ms

However, when I am trying to access ANY one of the existing endpoints, I am getting 404 back.

Now, also based on the logs, the request is actually hitting the server:

==> ./logs/localhost_access_log.2016-11-21.txt <==
172.17.0.1 - - [21/Nov/2016:07:15:09 +0000] "GET / HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:15:09 +0000] "GET / HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:16:45 +0000] "GET / HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:17:01 +0000] "GET / HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:17:07 +0000] "GET /index HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:28:24 +0000] "GET /api/user/register HTTP/1.1" 404 -
172.17.0.1 - - [21/Nov/2016:07:28:46 +0000] "POST /api/user/register HTTP/1.1" 404 -

How do I even approach this problem how to debug it? What am I missing? There is nothing special in the logs.

Also, I tried different versions of tomcat, including the exact one that runs on AWS EBS. Also, tried proxing the request through nginx, same result.

like image 541
Shurik Agulyansky Avatar asked Nov 21 '16 07:11

Shurik Agulyansky


1 Answers

You war file name is priz-0.5.war. So the context name is also priz-0.5. You have to call for example http://localhost:8080/priz-0.5

If you want to call it like http://localhost:8080/ just rename the war-File to ROOT.war

like image 130
dieter Avatar answered Sep 18 '22 01:09

dieter