Search code examples
spring-bootcxfspring-boot-actuator

Spring Boot 2.5.5, CXF 3.4.5, Actuator - Missing actuator endpoints


I am using Spring Boot 2.5.5 and CXF WS 3.4.5 to create a microservice, which will be on cloud. One of the requirements is to have a actuator. Monitoring services will check periodically if microservice is available.

I have the following code to publish endpoint

         @Bean
         public EndpointImpl endpoint() {
              EndpointImpl endpoint = new EndpointImpl(bus, serviceName);
              endpoint.getInInterceptors().add(wSS4JInInterceptor());
              endpoint.getInInterceptors().add(loggingInInterceptor);
              endpoint.getOutInterceptors().add(loggingOutInterceptor);
              endpoint.setBindingUri(SOAP12HTTP_BINDING);
              endpoint.publish("/servicename-service");
              return endpoint;
         }

WSDL is accessable via localhost:8082/service/servicename-service?wsdl

However, localhost:8082/actuator returns Whitelabel Error Page (404 Not Found). I tried many solutions from this and other website but none of it works.

I added the following code but it didnt help

    @Bean
    public ServletRegistrationBean cxfServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/service/*");
    }

I tried also to override dispatcherServlet but it didnt help aswell.

    @Bean
    public DispatcherServlet dispatcherServlet() {
        return new DispatcherServlet();
    }

    @Bean
    public ServletRegistrationBean dispatcherServletRegistrationBean() {
        ServletRegistrationBean dispatcherServlet = new ServletRegistrationBean(dispatcherServlet(), "/*");
        dispatcherServlet.setOrder(2);
        dispatcherServlet.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return dispatcherServlet;
    }

Solution

  • I don't exactly what failed during the process but it works without any problem right now. Those steps helped:

    1. remove spring-boot-starter-actuator from dependencies
    2. mvn clean install
    3. rebuild project
    4. add again spring-boot-starter-actuator to dependcies
    5. mvn clean install
    6. start project and see that both actuator and wsdl work

    I even removed cxfServlet and set cxf.path=/service in application.yml to stay consistent with current functionality.