I did this tutorial to migrate an old jsp application to spring boot. But instead of maven i used gradle. In IntelliJ Idea everythings works as expceted. Now i want to make a docker container of this application and therefore i used jib gradle plugin. But when i run this docker container i get an error "There was an unexpected error (type=Not Found, status=404). /WEB-INF/jsp/index.jsp". And indeed the /WEB-INF/jsp directory is missing in the docker container. So i added it via jib extraDirectories parameter, but still it wasn't found. So where is Spring looking for this files? Where do i have to put my files? Is it possible to change this directory with a property?
Asked
Active
Viewed 449 times
2 Answers
0
The Spring doc says
JSP Limitations
When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support.
- With Jetty and Tomcat, it should work if you use war packaging. ... JSPs are not supported when using an executable jar.
You can get more information in this SO question too.
I looked into the tutorial link you provided, and I see the project packaging is jar
and not war
. Probably you'll need to convert your project to a war
project by applying the Gradle WAR plugin.

Chanseok Oh
- 3,920
- 4
- 23
- 63
0
After hours of debugging i found out, that i could set the directory of jsp files by setting the document root of ServletWebServerFactory.
@Configuration
public class TomcatConfig {
@Value("${tomcat.server.document-root}")
String documentRoot;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
File documentRootFile = new File(documentRoot);
tomcat.setDocumentRoot(documentRootFile);
return tomcat;
}
}
This solved the problem for me.

cathixx
- 111
- 4