title: Whitelabel Error Page There was an unexpected error (type=Not Found, status=404). /WEB-INF/views/home.jsp
body: <p>I am following Spring in Action (part 2) and trying to create the Spittr application as the book shows. 
  <code>(with Spring Tool Suite 7.3.7. and Maven.)</code></p>
  
  <p>The problem is that I am getting the following error:</p>
  
  <blockquote>
    <p>Whitelabel Error Page.</p>
    
    <p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>
    
    <p>Thu Apr 07 16:21:23 CEST 2016
    There was an unexpected error (type=Not Found, status=404). /WEB-INF/views/home.jsp</p>
  </blockquote>
  
  <p>The package structure is:</p>
  
  <p><img src="https://i.stack.imgur.com/XGv53.png" alt="image here"></p>
  
  <p>As you see I tried to place the <code>/WEB-INF/views/home.jsp</code> in several places in, case there was a problem with the path.</p>
  
  <p>DispatcherServlet Configuration Class:</p>
  
  <pre><code>package com.spittr.config;
  
  import  org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  public class SpittrWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer
  {
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/" };
      }
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
      return new Class&lt;?&gt;[] { RootConfig.class };
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
      return new Class&lt;?&gt;[] { WebConfig.class };
      }
  }
  </code></pre>
  
  <p>WebConfig.java class:</p>
  
  <pre><code>package com.spittr.config;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.autoconfigure.web.ErrorAttributes;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @Configuration
  @EnableWebMvc
  @ComponentScan("com.spitter.web")
  public class WebConfig extends WebMvcConfigurerAdapter
  {
      @Bean
      public ViewResolver viewResolver() {
      InternalResourceViewResolver resolver = new InternalResourceViewResolver();
      resolver.setPrefix("/WEB-INF/views/");          
      resolver.setSuffix(".jsp");
      resolver.setExposeContextBeansAsAttributes(true);
      return resolver;
      }
  
      @Override
      public void configureDefaultServletHandling(
      DefaultServletHandlerConfigurer configurer) {
      configurer.enable();
      }
  }
  </code></pre>
  
  <p>RootConfig.java class:
  package com.spittr.config;</p>
  
  <pre><code>import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.ComponentScan.Filter;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.FilterType;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  
  @Configuration
  @ComponentScan(basePackages={"spitter"},
  excludeFilters={
  @Filter(type=FilterType.ANNOTATION, value=EnableWebMvc.class)})
  public class RootConfig {
  }
  </code></pre>
  
  <p>The @Controller class.</p>
  
  <pre><code>package com.spittr.web;
  
  import static org.springframework.web.bind.annotation.RequestMethod.*;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  public class HomeController 
  {
      @RequestMapping(value="/", method=GET)
      public String home() 
      {
          return "home";
      }
  }
  </code></pre>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com&lt;/groupId&gt;
      &lt;artifactId&gt;spittr&lt;/artifactId&gt;
      &lt;version&gt;1.2.0&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;Spittr&lt;/name&gt;
      &lt;description&gt;Test 1&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.3.3.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;java.version&gt;1.7&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>home.jsp:</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ page session="false" %&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Spittr&lt;/title&gt;
          &lt;link rel="stylesheet"
          type="text/css"
          href="&lt;c:url value="/resources/style.css" /&gt;" &gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Welcome to Spittr&lt;/h1&gt;
              &lt;a href="&lt;c:url value="/spittles" /&gt;"&gt;Spittles&lt;/a&gt; |
              &lt;a href="&lt;c:url value="/spitter/register" /&gt;"&gt;Register&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Basically is the same that you can find in the book. 
  I simply don't know what else to do.</p>
  
  <p>Thanks.</p>