Hello, I am new to working with Docker and trying to run a WAR file in tomcat container.(9.0.14-jre8)
Container is successfully up and running and ,
http://localhost:8080 - I am able to see Tomcat home page
http://localhost:8080/docs - I am able to see the docs page and similarly able to access the examples as well.
However, whne I try to access the resources on my war file - I always get 404 not found.
Same application works just fine on standard tomcat server in a not containerized environment.
I see lot of posts on this issue on different online forums as well. But, couldn’t find yet any thread explaining the reason behind this.
Any thoughts ? Appreciate your help.
I have the same issue on both tomcat and bitnami/tomcat containers. Did you find any solution?
Not very sure if we both are having the same issue. But, I can explain how I got mine resolved.
As I was packaging my application into a war file and copying the war file onto tomcat’s webapps directory as part of my image creation, Couple of issues here that I ran into.
First - Springboot main application needs to extend “SpringBootServletInitializer” and override the configure method.
I didn’t have to do this if I package my application as JAR file.
Second - In the Docker file - before copying the war file onto tomcat, need to add a user ‘tomcat’ and change the ownership of tomcat folder path /usr/local/tomcat to newly created user ‘tomcat’ from ‘root’.
from registry …tomcatXXXX
RUN adduser -D tomcat; chown -R tomcat:tomcat /usr/local/tomcat
Set user to ‘tomcat’
COPY localdir/youwar.war /usr/local/tomcat/webapps/yourwar.war
Hope that helps.
You are correct my issue was different. I had a much simpler problem. My container was running Java 11 whereas my WAR file was developed on Java 8. The framework I used to build the java application used JAXB, and those methods are now deprecated and excluded from Java 11.
I downgraded the JVM to Java 8 and I was able to run my application without problems.
Goes to show that I should have just looked at the log files instead of panicking. My bad.