My app works just fine if I run the application on my host using the
mvn spring-boot:run but when I deploy it on docker, it does not work and I get this error:
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/store/index", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/store/index", template might not exist or might not be accessible by any of the configured Template Resolvers
but if I go on the url: http:localhost:8080/login which is controlled by spring security, renders the template normally. Seems to be a permission problem but I'm not sure.
here is my Dockerfile:
FROM openjdk VOLUME /tmp RUN touch engdevcommerce.jar COPY target/engdevcommerce.jar engdevcommerce.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/engdevcommerce.jar"] Solution: Turns out the problem I was having, had nothing to do with the docker deployment. I ran the jar file on my host, and I was getting the same error. The problem was that, where I returned the view url at the controllers methods, I was starting with slash like this: "/.../..." . And spring does not load view with double slash when the application is packed as .jar file. I had to remove the slash character at the beginning of the url every where I returned a ModelAndView and at the th:insert tags too on my html files.
this link helped me a lot : spring-boot-thymeleaf-not-resolving-fragments-after-packaging