title: Spring Boot Application - 404 Not Found on tomcat
body: <p>I've read a ton of questions about this already, but none of them helped. 
  I'm building a very simple rest application, but the controllers are not responsing to request and I get this error: </p>
  
  <pre><code>HTTP Status 404 – Not Found
  Type Status Report
  
  Message /
  
  Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
  
  Apache Tomcat/8.5.23
  </code></pre>
  
  <p>I've put <code>System.out</code> in controllers that's also not shown so the methods aren't even called. </p>
  
  <p>My project stucture is: </p>
  
  <p><a href="https://i.stack.imgur.com/Ng6Il.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ng6Il.png" alt="enter image description here"></a></p>
  
  <p>The Application class is under <code>app</code> package. </p>
  
  <p>config: </p>
  
  <pre><code>@Configuration
  @EnableTransactionManagement
  public class DatabaseConfig {
  
  
  @Autowired
  private Environment env;
  
  @Bean(name = "dataSource")
  public DataSource dataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName(env.getProperty("db.driver"));
      dataSource.setUrl(env.getProperty("db.url"));
      dataSource.setUsername(env.getProperty("db.username"));
      dataSource.setPassword(env.getProperty("db.password"));
      return dataSource;
  }
  
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
      LocalContainerEntityManagerFactoryBean entityManagerFactory =
              new LocalContainerEntityManagerFactoryBean();
  
      entityManagerFactory.setDataSource(dataSource());
  
      // Classpath scanning of @Component, @Service, etc annotated class
      entityManagerFactory.setPackagesToScan(
              env.getProperty("entitymanager.packagesToScan"));
  
      // Vendor adapter
      HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
      entityManagerFactory.setJpaVendorAdapter(vendorAdapter);
  
      // Hibernate properties
      Properties additionalProperties = new Properties();
      additionalProperties.put(
              "hibernate.dialect",
              env.getProperty("hibernate.dialect"));
      additionalProperties.put(
              "hibernate.show_sql",
              env.getProperty("hibernate.show_sql"));
      additionalProperties.put(
              "hibernate.hbm2ddl.auto",
              env.getProperty("hibernate.hbm2ddl.auto"));
      entityManagerFactory.setJpaProperties(additionalProperties);
  
      return entityManagerFactory;
  }
  
  @Bean
  public JpaTransactionManager transactionManager() {
      JpaTransactionManager transactionManager =
              new JpaTransactionManager();
      transactionManager.setEntityManagerFactory(
              entityManagerFactory().getObject());
      return transactionManager;
  }
  
  @Bean
  public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
      return new PersistenceExceptionTranslationPostProcessor();
  }
  }
  </code></pre>
  
  <p>controller: </p>
  
  <pre><code>@Controller
  public class CharacterController {
  
  @RequestMapping(value="/", method= RequestMethod.GET)
  public  String start() {
      System.out.println("Start");
      return "Hello.";
  }
  </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;xxxxxxxxxxx&lt;/groupId&gt;
  &lt;artifactId&gt;xxxxxxxxxxxxxxx&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;xxxxxxxxxxxxxxxxx&lt;/name&gt;
  &lt;description&gt;xxxxxxxxxxxxxxxxxxxxxx&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.5.9.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent fapp.repositorytory --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&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-tomcat&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&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;!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;5.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-web --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;5.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jsoup&lt;/groupId&gt;
          &lt;artifactId&gt;jsoup&lt;/artifactId&gt;
          &lt;version&gt;1.11.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/postgresql/postgresql --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.4-1206-jdbc42&lt;/version&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>Application: </p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAutoConfiguration
  public class Application {
  
  public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
  }
  }
  </code></pre>
  
  <p>I also tried using <code>@SpringBootApplication</code>, putting <code>(basePackages ={"app","app.config" etc})</code>, just <code>app</code>, controller class... Even moving all classes to the same package but I'm now convinced this is not the issue. </p>
  
  <p>The console log ends with: </p>
  
  <pre><code>2018-01-27 00:08:08.291  INFO 14596 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
  2018-01-27 00:08:09.634  INFO 14596 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2018-01-27 00:08:10.584  INFO 14596 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
  2018-01-27 00:08:10.632  INFO 14596 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
  2018-01-27 00:08:10.637  INFO 14596 --- [           main] app.Application                          : Started Application in 38.878 seconds (JVM running for 39.335) 
  </code></pre>
  
  <p>so it looks like it should work...</p>
  
  <p>Enviroment class: </p>
  
  <pre><code>package org.springframework.core.env;
  
  public interface Environment extends PropertyResolver {
  String[] getActiveProfiles();
  
  String[] getDefaultProfiles();
  
  boolean acceptsProfiles(String... var1);
  }
  </code></pre>