-
Notifications
You must be signed in to change notification settings - Fork 41.2k
When using the Actuator, an app with a custom DispatcherServlet bean named dispatcherServlet fails to start #13527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am facing this issue at work. The workaround I found at the moment is to add the missing bean, like this: import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class DispatcherServletPathProvider implements org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider {
@Value("${server.servlet.context-path}")
private String servletContextPath;
@Override
public String getServletPath() {
return servletContextPath;
}
} I don't know whether having a default implementation like this for this bean would solve the issue generically? |
@lpetit-yseop That's a good workaround, but I think you want to use A generic solution is more complicated if we want to cope with custom dispatcher servlet registration beans. They may not be using the |
Thank you for the confirmation. I am having a hard time truly understanding the relation between Did I miss some place where it is documented, like "the full real path for controllers results in |
So, if I want my workaround to be more resilient to future unexpected changes, should I be using a combination of |
I was looking at the fix done for #13106 . Unfortunately the fix is breaking a few of our integration test when we are trying to upgrade to SpringBoot 2.0.3 from 2.0.2. It's for scenarios when need MVC context with Jersey. We need MVC with Jersey for cases when we need to serve static files? We are seeing the following error
I feel line 57 in ServletEndpointManagementContextConfiguration.java should have another condition as The work around we are using for now is to have the following config in our tests @Bean
@Primary
public DispatcherServletPathProvider testDispatcherServletPathProvider() {
return () -> "";
} |
@ranarula I think that's a slightly different issue than the one being discussed here. Could you raise a separate issue with a minimal sample that reproduces the behavior you described? |
Thanks @mbhave, Will create a sample and an issue but seems its related to this in a sense that in my case instead of a custom DispatcherServlet we have a real DispatcherServlet (class & not bean) in the context Though looking at it closely seems just adding the the above suggested change might not work alone as there is |
The changes made to fix #12934 and #13106 mean that an app like this:
Will fail to start with a failure like this:
I'm not entirely sure how to fix this. We need to get hold of the dispatcher servlet that's going to dispatch to any servlet endpoints and get the path to which it's mapped.
EndpointRequest
falls back to""
if there's noDispatcherServletPathProvider
but I'm not sure that's right either.The text was updated successfully, but these errors were encountered: