Reputation: 79
I'm using Jersey starter in my web application.
org.springframework.boot spring-boot-starter-jersey 1.4.2.RELEASE
Trying to integrate the Actuator endpoints into my application.Used the following maven dependency
org.springframework.boot spring-boot-starter-actuator 1.5.2.RELEASE org.springframework.boot spring-boot-starter-web 1.5.2.RELEASE
When I access the health endpoint, it was giving me 404 error. http://localhost:8080/context/health
Do I need to add any other configuration class to my application that will initialize the actuator? Can anyone point me in the correct direction?
Upvotes: 2
Views: 4760
Reputation: 11115
This is how i was able to ti get this working
Step 1 By default Jersey will be set up resource configured by extends ResourceConfig as serverlate. We need to tell spring boot to use it as filter. Set it as using below property
spring .jersey.type: filter
Step 2
I was using below configuration for registering resources
@component
public class MyResourceConfig extends ResourceConfig {
public MyResourceConfig () {
try {
register(XXX.class);
} catch (Exception e) {
LOGGER.error("Exception: ", e);
}
}
}
Change @component
to @Configuration
and also add below property property(ServletProperties.FILTER_FORWARD_ON_404, true);
Final Configuration
@Configuration
public class LimitResourceConfig extends ResourceConfig {
public LimitResourceConfig() {
try {
register(XXX.class);
property(ServletProperties.FILTER_FORWARD_ON_404, true);
} catch (Exception e) {
LOGGER.error("Exception: ", e);
}
}
}
Upvotes: 0
Reputation: 209122
Most likely you are using /*
(default if not specified) for the Jersey mapping. The problem is that Jersey will get all the request. It does not know that it needs to forward to any actuator endpoints.
The solutions are described in this post. Either change the mapping for Jersey, or change Jersey to be used as filter instead of a servlet. Then set the Jersey property to forward requests for URLs it doesn't know.
Upvotes: 2