title: The requested resource is not available. Can't display the welcome page
body: <p>I try to display the welcome page, but always get</p>
  
  <p><em>The requested resource is not available.</em></p>
  
  <p>I'm using java to configure spring mvc. </p>
  
  <p>The IDE is STS. Maven is used to import dependencies.</p>
  
  <p>There is this row in the console output.</p>
  
  <pre><code>WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:reader' did not find a matching property.
  </code></pre>
  
  <p>Configuration File</p>
  
  <pre><code>    package com.reader.config;
  
  import java.util.Properties;
  
  import javax.annotation.Resource;
  import javax.sql.DataSource;
  
  import org.hibernate.jpa.HibernatePersistenceProvider;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.core.env.Environment;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  import org.springframework.jdbc.datasource.DriverManagerDataSource;
  import org.springframework.orm.jpa.JpaTransactionManager;
  import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.view.JstlView;
  import org.springframework.web.servlet.view.UrlBasedViewResolver;
  
  @Configuration
  @EnableWebMvc
  @EnableTransactionManagement
  @ComponentScan("com.reader")
  @PropertySource("classpath:application.properties")
  @EnableJpaRepositories("com.reader.repository")
  public class AppConfig {
  
      private static final String PROPERTY_NAME_DATABASE_DRIVER = "db.driver";
      private static final String PROPERTY_NAME_DATABASE_PASSWORD = "db.password";
      private static final String PROPERTY_NAME_DATABASE_URL = "db.url";
      private static final String PROPERTY_NAME_DATABASE_USERNAME = "db.username";
  
      private static final String PROPERTY_NAME_HIBERNATE_DIALECT = "hibernate.dialect";
      private static final String PROPERTY_NAME_HIBERNATE_SHOW_SQL = "hibernate.show_sql";
      private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN = "entitymanager.packages.to.scan";
  
      @Resource
      private Environment env;
  
  
  
      @Bean
      public UrlBasedViewResolver viewResolver() {
          UrlBasedViewResolver resolver = new UrlBasedViewResolver();
          resolver.setPrefix("/WEB-INF/views/");
          resolver.setSuffix(".jsp");
          resolver.setViewClass(JstlView.class);
          return resolver;
      }
  
      @Bean
      public DataSource dataSource() {
          DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
          dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
          dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
          dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
          dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));
  
          return dataSource;
      }
  
      @Bean
      public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
          LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
          entityManagerFactoryBean.setDataSource(dataSource());
          entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
          entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
  
          entityManagerFactoryBean.setJpaProperties(hibProperties());
  
          return entityManagerFactoryBean;
      }
  
      private Properties hibProperties() {
          Properties properties = new Properties();
          properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
          properties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
          return properties;
      }
  
      @Bean
      public JpaTransactionManager transactionManager() {
          JpaTransactionManager transactionManager = new JpaTransactionManager();
  
  
  transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
          return transactionManager;
      }
  
  
  }
  </code></pre>
  
  <p>Innitializer</p>
  
  <pre><code>package com.reader.config;
  
  import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class[] { AppConfig.class };
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return null;
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/" };
      }
  
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>    package com.reader.controller;
  
  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 = { "/", "/home" }, method = RequestMethod.GET)
      public String goHome() {
          return "home";
      }
  
  }
  </code></pre>
  
  <p>home.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Home&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;c:url value="/getOne.jsp" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&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;reader&lt;/groupId&gt;
      &lt;artifactId&gt;reader&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;springframework.version&gt;4.0.6.RELEASE&lt;/springframework.version&gt;
          &lt;hibernate.version&gt;4.3.10.Final&lt;/hibernate.version&gt;
          &lt;mysql.connector.version&gt;5.1.31&lt;/mysql.connector.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
  
          &lt;!-- Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;${springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
              &lt;version&gt;1.10.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Hibernate --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-jpa-2.1-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.0.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;!-- MySQL --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;${mysql.connector.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Servlet+JSP+JSTL --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.5.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Changing viewresolver to this didn't help</p>
  
  <pre><code>@Bean
      public ViewResolver viewResolver() {
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setViewClass(JstlView.class);
          viewResolver.setPrefix("/WEB-INF/views/");
          viewResolver.setSuffix(".jsp");
  
          return viewResolver;
      }
  </code></pre>
  
  <p>getOne.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;User Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It's controller</p>
  
  <pre><code>package com.reader.controller;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  import com.reader.model.User;
  import com.reader.service.UserService;
  
  @Controller
  public class UserController {
  
      @Autowired
      UserService userService;
  
      @RequestMapping(value = { "/getOne" }, method = RequestMethod.GET)
      public String getOne(ModelMap model) {
          User user = userService.getOne(1);
          model.addAttribute("user", user);
          return "getOne";
      }
  }
  </code></pre>
  
  <p>UserRepository.java</p>
  
  <pre><code> package com.reader.repository;
  
   import org.springframework.data.jpa.repository.JpaRepository;
  
   import com.reader.model.User;
  
   public interface UserRepository extends JpaRepository&lt;User, Integer&gt; {
  // @Query("select b from Bank b where b.name = :name")
  // Bank findByName(@Param("name") String name);
   }
  </code></pre>
  
  <p>application.properties</p>
  
  <pre><code>#DB properties:
  db.driver=com.mysql.jdbc.Driver
  db.url=jdbc:mysql://localhost:3306/reader
  db.username=root
  db.password=
  
  #Hibernate Configuration:
  hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  #turn off the hib,use the log4jdbc instead.
  hibernate.show_sql=true
  entitymanager.packages.to.scan=com.reader.model
  </code></pre>