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?
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<Topic> 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);
}
}
http://localhost:8080/topics/java ---- works with embedded server
http://localhost8080/topics/java ------ does not work in tomcat 8(external)
http://localhost8080/SpringBootWithSpringDataJPA/topics/java ------ does not work in tomcat 8(external) where SpringBootWithSpringDataJPA is my project name.
The application.properties file is :
spring.datasource.jndi-name=java:/comp/env/jdbc/postgres/springbootDS
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
localhost:8080/SpringBootWithSpringDataJPA-0.0.1-SNAPSHOT/...