Spring-Boot Not Finding JSP Pages in WAR File

By : node42
Source: Stackoverflow.com

When running a spring-boot project (java -jar /path/to/war.war) .jsp files are not found.

Methods annotated with @ResponseBody work fine. The view resolver is coming up with the correct path to the JSP pages, but they are not found. This project has one configuration class and no web.xml.

Configuration Class:

@ComponentScan (basePackages = "org.ghc.security.web")
class ScMain extends WebMvcConfigurerAdapter {

    // SpringBoot BootStrap...
    static void main (String[] args) {
        ApplicationContext ctx = SpringApplication.run (ScMain, args)

        System.out.println("Let's inspect the beans provided by Spring Boot:");

        String[] beanNames = ctx.getBeanDefinitionNames();
        beanNames.each { beanName ->

    InternalResourceViewResolver internalResourceViewResolver () {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver()


class Running {

    @RequestMapping ("/alive")  // This works fine
    String amIAlive () {

    @RequestMapping ("/alive/page")  // Path to page resolved, but file not found!
    ModelAndView amIAlivePage () {
        new ModelAndView("alivepage")

Error Log

2013-11-25 09:08:28.714 ERROR 1549 --- [tp1945397783-20] org.apache.jasper.servlet.JspServlet : PWC6117: File "%2FUsers%2Fnode42%2FDevelopment%2Fmock-security-ui%2Fbuild%2Flibs%2Fmock-security-ui-2.06-SNAPSHOT.war%2FWEB-INF%2Fjsp%2Falivepage.jsp" not found

The path to the .war file in the log entry is correct, and the path in the war file (WEB-INF/jsp/alivepage.jsp) is correct. The response is the same whether using Jetty or Tomcat (the above log was from Jetty). I have also tried not using the view resolver, specifying one as above, or setting the view resolver through properties. I am completely flummoxed as everything actually looks like it is working, except for this one little detail. And the @ResponseBody annotated method in the controller works fine.

If anyone has any suggestions I'd certainly appreciate the input!

By : node42


I don't know your pom.xml but this seems similar to this thread

JSP file not rendering in Spring Boot web application

Try adding dependency list to your pom please.

This video can help you solving your question :)
By: admin