I am developing a simple application using Spring Boot plus Spring Web Starter. This is very good when I test the integrated Tomcat server (JAR packaging). I need to debug some things, so I thought it would be better to deploy it as a WAR on an external Tomcat server (or indeed on an external Pivotal tc Server bundled with STS).
I followed the procedures outlined in the Spring Boot Documentation , and when I start the application, I see the logs loading my controllers, requests, etc. (Yay? Nay.). As soon as the container gets up, any queries result in an ugly 404.
I understand that Spring Boot will spawn a Servlet 3 compatible container, so the web.xml does not have to be strictly required. All I have to do is specify the entry point of the application to the class that extends SpringBootServletInitializer . Here he is:
package com.company.ci.integration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; @SpringBootApplication public class GitlabWebhookProcessingApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(GitlabWebhookProcessingApplication.class, args); } @Override protected SpringApplicationBuilder configure( SpringApplicationBuilder application) { return application.sources(GitlabWebhookProcessingApplication.class); } }
I point this class to my POM file as follows:
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <start-class>com.chemtech.ci.integration.GitlabWebhookProcessingApplication</start-class> <java.version>1.7</java.version> </properties>
As stated in the above documentation, this should magically work, and my application will load and work as expected.
Ah, here are the logs:
Servlet Mappings:
2015-06-07 20:21:16.870 INFO 3373 --- [ost-startStop-1] osbceServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2015-06-07 20:21:16.871 INFO 3373 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*] 2015-06-07 20:21:16.872 INFO 3373 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2015-06-07 20:21:16.872 INFO 3373 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
Display controller actions:
2015-06-07 20:21:20.278 INFO 3373 --- [ost-startStop-1] swsmmaRequestMappingHandlerMapping : Mapped "{[/webhooks/mergeRequestComment],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.chemtech.ci.integration.controller.WebhookController.MergeRequestCommentReceiver(java.lang.String,com.chemtech.ci.integration.model.MergeRequestCommentEventRequestBody) 2015-06-07 20:21:20.282 INFO 3373 --- [ost-startStop-1] swsmmaRequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2015-06-07 20:21:20.282 INFO 3373 --- [ost-startStop-1] swsmmaRequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
It is important to emphasize that this works great using an executable JAR with an embedded server. I scratch my head a bit and even try to do as indicated in other SO threads:
Spring Download - Custom 404 page with standalone tomcat
http://forum.spring.io/forum/spring-projects/web/745458-spring-boot-v1-0-0-rc3-not-resolving-views-404-error (not fully related)
Am I doing something wrong here? (well, of course, it's me. This is a purely rhetorical question)
Any help would be greatly appreciated.
Thanks!