Issue
I have a project setup with spring boot 1.4.2 and CXF JAXRS. I want to add spring boot actuator to the project. This is the configuration which I added to the project.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
I create a WAR file after this and then deploy it in external tomcat server. But when I access the health URL localhost:8080/management/health it is giving 404 HTTP code. The server starts properly and I can see the logs with following details:
Health configuration log
[localhost-startStop-1] INFO org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping - Mapped "{[/management/health || /management/health.json],produces=[application/json]}" onto public java.lang.Object
Servlet(s) configuration log
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean - Mapping filter: 'springSecurityFilterChain' to: [/*]
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'webRequestLoggingFilter' to: [/*]
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'applicationContextIdFilter' to: [/*]
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'dispatcherServletRegistration' to []
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/]
[localhost-startStop-1] INFO org.springframework.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'CXFServlet' to [/services/*]
Solution
Issue is solved and here is the details. Since CXF and spring boot together were together cofigured, both CXF REST API and actuator end point were configured for '/'. The name of servlet bean configured for CXF RESt end point is dispatcherServletRegistration. An auto configuration for CXF servlet was also happening since boot starter for CXf was there in the POM. Hence you can find CXFServlet also configured for /services/*.
Mapping servlet: 'dispatcherServletRegistration' to []
Mapping servlet: 'dispatcherServlet' to [/]
Mapping servlet: 'CXFServlet' to [/services/*]
I removed auto configuration option (CXFServlet) since I have some customization required for the CXF JAXRS implementation and mapped dispatcherServletRegistration to /services/* and now everything is working fine. Now actuator works under '/' and CXF REST APIs under /services.
Answered By - Ganesh Shenoy
Answer Checked By - Mildred Charles (JavaFixing Admin)