-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Hi,
we struggle getting our error pages configured using Spring Boot(1.1.4.RELEASE) and wicket 6 with java-based configuration (no web-xml). We use the DispatcherServlet to provide additional REST endpoints
Our filter-chain config looks like this:
@Bean
public FilterRegistrationBean wicketFilter() {
FilterRegistrationBean bean = new FilterRegistrationBean();
WicketFilter filter = new WicketFilter(ourApplication());
filter.setFilterPath("");
bean.setFilter(filter);
bean.addUrlPatterns("/*");
return bean;
}
@Bean
public ServletRegistrationBean dispatcherRegistration(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet);
// since servlets come after filters, wicket gets first chance to handle requests
registration.addUrlMappings("/*");
return registration;
}
What we want are error pages that are served by wicket, e.g. we have a page mounted at /404 that should be used for 404 pages. However we currently only get the "Whitelabel Error Page" provided by Spring boot, saying: "This application has no explicit mapping for /error, so you are seeing this as a fallback.".
We tried different approaches, like http://sporcic.org/2014/05/custom-error-pages-with-spring-boot/, but this does not do true browser redirects it seems (our /404 mounted page is not used, instead the dispatcherServlet reports a failure to find a mapping for /404).
When trying to write a custom Controller for "/error", we get this eror which seems to be cause by Spring boot eagerly mounting the whitelabel error page:
Ambiguous mapping found. Cannot map 'basicErrorController' bean method
public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
to {[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'errorController' bean method
public void de.gulp.backend.rest.ErrorController.error() mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
When using the DispatcherServlet only for urls Mappings "/rest/*", the wicket mechanism for providing 404 page still does not work.
Any idea?