title: Spring Boot: Rest URL returns 404
body: <p>I am developing a simple Spring Boot base rest application which has been deployed into an external tomcat server, with jndi data source. When I run the application the database gets created, this means the application is able to read the Entity classes and create hibernate ddl. However, when I try to hit the rest url from postman a 404 error message is returned. This has happened after I have moved my application to an external server, when I was using the embeded server I was able to hit the urls. Can someone help me figure out what am I doing wrong?</p>
  
  <pre><code>Main method:
  
  package com.nb;
  
  @SpringBootApplication
  public class SpringBootWithSpringDataJpaApplication extends SpringBootServletInitializer{
  
  public static void main(String[] args) {
      SpringApplication.run(SpringBootWithSpringDataJpaApplication.class, args);
  }
  
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
      return application.sources(SpringBootWithSpringDataJpaApplication.class);
  }
  
  Controller:
  package com.nb.springboot.topic;
  @RestController
  public class TopicController {
  
  @Autowired
  private TopicService topicService;
  
      @RequestMapping("/topics")
      public List&lt;Topic&gt; getAllTopics(){
          return topicService.getAllTopics();
      }
  
      @RequestMapping("/topics/{id}")
      public Topic getTopic(@PathVariable("id") String id){
          return topicService.getTopic(id);
      }
  
      @RequestMapping(method=RequestMethod.POST, value="/topics")
      public void addTopic(@RequestBody Topic topic){
          topicService.addTopic(topic);
  
      }
  
      @RequestMapping(method=RequestMethod.PUT, value="/topics/{id}")
      public void updateTopic(@RequestBody Topic topic, @PathVariable String id){
          topicService.updateTopic(topic, id);
      }
  
      @RequestMapping(method=RequestMethod.DELETE, value="/topics/{id}")
      public void deleteTopic(@PathVariable String id){
          topicService.deleteTopic(id);
      }
  </code></pre>
  
  <p>}</p>
  
  <p><a href="http://localhost:8080/topics/java" rel="nofollow noreferrer">http://localhost:8080/topics/java</a>  ---- works with embedded server</p>
  
  <p><a href="http://localhost8080/topics/java" rel="nofollow noreferrer">http://localhost8080/topics/java</a>  ------ does not work in tomcat 8(external)</p>
  
  <p><a href="http://localhost8080/SpringBootWithSpringDataJPA/topics/java" rel="nofollow noreferrer">http://localhost8080/SpringBootWithSpringDataJPA/topics/java</a>  ------ does not work in tomcat 8(external) where SpringBootWithSpringDataJPA is my project name.</p>
  
  <p>The application.properties file is :</p>
  
  <p>spring.datasource.jndi-name=java:/comp/env/jdbc/postgres/springbootDS</p>
  
  <p>spring.jpa.hibernate.ddl-auto=create</p>
  
  <p>spring.jpa.show-sql=true</p>