404 on tomcat even if there is the app inside webapps

Hi all, I’m new to doker and I have almost the same issue reported in:

The main difference is that I do not have a webapp.dist directory created but in my case there is my app inside the webapp direcotory, and from looking at the log it has been deployed correctely.

this is my Dockefile

FROM tomcat:9.0-alpine
LABEL maintainer="deepak@softwareyoga.com"

ADD assessmentonline.war /usr/local/tomcat/webapps/

EXPOSE 8080
CMD ["catalina.sh", "run"]

and i run the following comand:

docker build -t mywebapp1 .

and after

docker run -p 80:8080 mywebapp1

the logs say:

22-Oct-2024 14:24:34.521 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 494 ms
22-Oct-2024 14:24:34.543 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
22-Oct-2024 14:24:34.543 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.2
22-Oct-2024 14:24:34.566 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/assessmentonline.war]
22-Oct-2024 14:24:38.019 INFO [main] 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.
22-Oct-2024 14:24:38.143 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/assessmentonline.war] has finished in [3,575] ms
22-Oct-2024 14:24:38.143 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
22-Oct-2024 14:24:38.314 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [170] ms
22-Oct-2024 14:24:38.314 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
22-Oct-2024 14:24:38.326 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [12] ms
22-Oct-2024 14:24:38.326 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
22-Oct-2024 14:24:38.339 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [13] ms
22-Oct-2024 14:24:38.339 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
22-Oct-2024 14:24:38.359 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [19] ms
22-Oct-2024 14:24:38.359 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
22-Oct-2024 14:24:38.373 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [14] ms
22-Oct-2024 14:24:38.376 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
22-Oct-2024 14:24:38.383 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
22-Oct-2024 14:24:38.387 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 3865 ms

If I go to the filesystem using Docker:

/usr/local/tomcat # ls
LICENSE         RELEASE-NOTES   bin             include         logs            temp            work
NOTICE          RUNNING.txt     conf            lib             native-jni-lib  webapps
/usr/local/tomcat # cd webapps/
/usr/local/tomcat/webapps # ls
ROOT                  assessmentonline      assessmentonline.war  docs                  examples              host-manager          manager
/usr/local/tomcat/webapps # cd assessmentonline/
/usr/local/tomcat/webapps/assessmentonline # ls
META-INF  WEB-INF   org
/usr/local/tomcat/webapps/assessmentonline #

but if I try to call it

C:\Windows\system32>curl http://localhost/assessmentonline/api/healthcheck
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> &#47;assessmentonline&#47;api&#47;healthcheck</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.2</h3></body></html>

what can be the issue? any help is appreciate

Looks like either a Tomcat problem, or a problem with the application you deploy on it. I feel a Tomcat forum would be a better place to ask about it, as it’s more likely Tomcat users containerize their apps, than Docker users that actually use Tomcat.

I am astonished that people still use standalone Tomcat today. Since Spring Boot is generally available, the only Tomcat instances I see are the ones embedded into the Spring Boot application.

thanks for your replay, I think you right but if the application works as a standalone application trasfer it to a docker container shoudn’t be so complicated, Anyway I also post the question on tomcat forum no help at all :slight_smile: