Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to disable ErrorPageFilter in Vaadin Spring boot application when deployed as war?
I am trying to solve a problem with Vaadin 24.9.10 Spring Boot 3.5.11 application deployed as war file for tomcat 10 on my server.
There are a lot of error log messages with varying request paths about ErrorPageFilter, which can not forward to error page since response has already been commited:
ERROR 1 --- [nio-8080-exec-9] o.s.b.w.servlet.support.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
This is happening only when application is deployed as war file to a tomcat container on the server. No error logs when running locally. I want to remove that logs when deployed to server (the log is not needed since I am using only default Vaadin views and not interfering with requests/responses or using custom error page paths or handling request/responses errors on spring level).
ErrorPageFilter bean is probably created by default by Vaadin/Spring boot when deployed as war file or by some default configuration. From ErrorPageFilter docs:
A Servlet Filter that provides an ErrorPageRegistry for non-embedded applications (i.e. deployed WAR files). It registers error pages and handles application errors by filtering requests and forwarding to the error pages instead of letting the server handle them. Error pages are a feature of the servlet spec but there is no Java API for registering them in the spec. This filter works around that by accepting error page registrations from Spring Boot's ErrorPageRegistrar (any beans of that type in the context will be applied to this server)
There is also an outdated unanswered post on vaadin forum referencing same error log, but from my understanding, in different context.
There is also an outdated answer on stack overflow site, which does not work for today's framework versions or perhaps there is an extra, which needs to be done (configured) to make it work:
@Configuration
public class AppInitializer implements WebApplicationInitializer {
@Bean
public ErrorPageFilter errorPageFilter() {
return new ErrorPageFilter();
}
@Bean
public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(filter);
filterRegistrationBean.setEnabled(false);
return filterRegistrationBean;
}
}
In this case, I get an exception: The bean 'errorPageFilter', defined in org.springframework.boot.web.servlet.support.ErrorPageFilterConfiguration, could not be registered. A bean with that name has already been defined in class path resource
Using @ConditionalOnBean(ErrorPageFilter.class) does not help (method is not called).
I am also using Vaadin's ErrorHandler to catch UI exceptions if it is relevant:
@Component
public class VaadinErrorHandler implements ErrorHandler {
@Override
public void error(final ErrorEvent event) {
...
}
}
Lastly, this is my class with @SpringBootApplication annotation:
@SpringBootApplication
@Theme(value = "myapp")
@PWA(name = "XXX", shortName = "XXX", iconPath = "icons/XXX.png", offlinePath = "XXX.html")
@Push(value = PushMode.MANUAL)
@EnableAsync
@EnableScheduling
public class Application extends SpringBootServletInitializer implements AppShellConfigurator {
// dev only
public static void main(final String[] args) throws Exception {
new SpringApplicationBuilder(Application.class)
.listeners(new DatabasePropertiesSetup())
.run(args);
}
// when deployed to servlet container
@Override
protected SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
return application.listeners(new DatabasePropertiesSetup())
.sources(Application.class);
}
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
val sessionCookieConfig = servletContext.getSessionCookieConfig();
servletContext.setSessionTimeout(60);
sessionCookieConfig.setHttpOnly(true);
sessionCookieConfig.setSecure(true);
sessionCookieConfig.setName("XXX");
super.onStartup(servletContext);
}
@Override
public void configurePage(final AppShellSettings settings) {
settings.addFavIcon("icon", "icons/XXX.png", "17x17");
}
}
1 answer
The following users marked this post as Works for me:
| User | Comment | Date |
|---|---|---|
| MarekChr | (no comment) | Mar 18, 2026 at 12:17 |
One of the solutions might be to use setRegisterErrorPageFilter of SpringBootServletInitializer class:
public class Application extends SpringBootServletInitializer implements AppShellConfigurator {
// keep no args constructor
public Application() {
setRegisterErrorPageFilter(false);
}
...

0 comment threads