We are trying to upgrade Spring boot app from 1.5.9 to 2.2.7. We use the following Servlet Registrations in the app:
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new DispatcherServlet());
Map<String, String> params = new HashMap<String, String>();
params.put("org.atmosphere.servlet", "org.springframework.web.servlet.DispatcherServlet");
params.put("contextClass", "org.springframework.web.context.support.AnnotationConfigWebApplicationContext");
registration.setInitParameters(params);
return registration;
}
@Bean
public ServletRegistrationBean configureJerseyForRESTfulWebService() {
ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/service/*");
registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName());
registration.addInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
return registration;
}
@Bean
public FilterRegistrationBean securityFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new SecurityFilter());
registration.addUrlPatterns("/*");
registration.setName("SecurityFilter");
registration.setOrder(1);
return registration;
}
After the upgrade, we are getting the following errors during startup and service unable to run:
Parameter 0 of method errorPageCustomizer in org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'dispatcherServletRegistration' in 'DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration' not loaded because DispatcherServlet Registration found servlet registration bean dispatcherServletRegistration
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' in your configuration.
Any hint how to resolve theses errors/issues. If possible please share any code example, thanks