Hi everyone,
I’m running a Tomcat 8.5 application inside a Docker container on my VPS, but I’m encountering an issue with a 404 error when accessing an endpoint that should be served by a deployed WAR file.
Here’s my setup:
Docker Compose file:
MySQL container (mysql-db)
Tomcat container (tomcat-app)
Both connected via a custom network bridge
Tomcat Dockerfile:
Multi-stage build that uses openjdk:8 for building the WAR file with Gradle
Then uses the mdelapenya/tomcat-mysql:7.0.77 image to run Tomcat 7.0.77 (I have tried with Tomcat 8.5 in docker-compose.yml)
WAR file: brain.war deployed to /opt/apache-tomcat-7.0.77/webapps/
The services are up and running without issues. I can access the Tomcat home page at http://vps111.host.al:8080, but when I try to access my app endpoint http://vps111.host.al:8080/facts/list, I get a 404 error.
Here’s what I’ve done so far:
Confirmed the WAR file was copied into /webapps/ folder.
Checked logs, and Tomcat starts successfully without deployment errors.
Verified URL mappings in Grails (UrlMappings.groovy) are correct.
Set environment variables in the container for MySQL datasource configuration.
Despite everything looking correct, the endpoint always returns a 404. Can anyone help troubleshoot why my application isn’t serving content on this endpoint?
Why should Tomcat load the brain.war file? As far as I know the fle should be called ROOT.war. If you have any setting that makes your file loadable, please, share.
I knew it could be configured, that is what I asked for it. If that is correct, maybe there is something with the image itself which supports an outdated Tomcat version. You could try the official repo or contact the image maintainer.
For now, I see nothing that indicates it is a Docker issue. Isn’t there some kind of Tomcat debug log you could enable to show what configuration files were applied and what rule loaded the webpage giving you 404?
I’m not sure why you quoted “backticks” from @bluepuma77’s answer, but I added it for you this time.
Next time, please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.
You should probably:
A. change the mysql db password
B. Use variable interpolation or env_file instead of writing the password in the compose file
C. If the database is not meant for external use, only by your other containers, unmap the ports to disallow external access
Since you have no problem with Docker, but the application inside, it isn’t really a Docker issue, so the compose and the dockerfile will not help much in this case, We could still help if you share the config file that makes you think it should map the url to the war file.
EDIT.: Your PM indicates you could not find the war file in the folder although you stated here the file was there. Let’s keep the conversation here so everyone can help. Also make sure you are using the same config or always point out when you changed the config as different config can have different errors and it is impossible to follow the issue without knowing which config caused it.
I even quoted your own message where you mentioned the filename. So I will not spend more time on asking for the same file, sorry. Maybe someone else would be able to comunicate more clearly if I failed.
And I still stand by my opinion that it is an application specific issue which should be discussed on a Java forum or with the image maintainer.
Additional note: this is not what containers are intended for. Their primary purpose is separation of concerns. You should use a Tomcat and a separate DB container, connect them with a Docker network. That way they are independent, no potential library difficulties, they can be independently upgraded.
And the image you have selected (link) seems to be already 7 years old, that’s really not the way to go.