How to disable ErrorPageFilter in Spring Boot?

membersound

I'm creating a SOAP service that should be running on Tomcat.
I'm using Spring Boot for my application, similar to:

@Configuration
@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)
public class AppConfig {
}


My webservice (example):

@Component
@WebService
public class MyWebservice {

    @WebMethod
    @WebResult
    public String test() {
        throw new MyException();
    }
}

@WebFault
public class MyException extends Exception {
}


Problem:
Whenever I throw an exception within the webservice class, the following message is logged on the server:

ErrorPageFilter: Cannot forward to error page for request [/services/MyWebservice] 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


Question:
How can I prevent this?

mzc

To disable the ErrorPageFilter in Spring Boot (tested with 1.3.0.RELEASE), add the following beans to your Spring configuration:

@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;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring Boot war file on tomcat: errorPageFilter cannot be cast to TomcatEmbeddedServletContainerFactory

From Dev

how to disable spring boot HibernateJpaAutoConfiguration

From Dev

how to disable spring boot HibernateJpaAutoConfiguration

From Java

How to disable some warnings in Spring Boot

From Java

how to disable spring boot logo in stdout?

From Dev

Spring Boot - How to disable @Cacheable during development?

From Dev

How to disable Hibernate validation in a Spring Boot project

From Dev

How to disable logback ConsoleAppender in Spring Boot

From Dev

How to disable security in Spring-Boot 2?

From Dev

How to disable `@EnableKafka` in Spring Boot tests?

From Dev

How to disable console logging in spring-boot?

From Dev

How disable scanning @Configuration class in Spring boot

From Dev

How to disable write operation for Jolokia in Spring boot?

From Dev

How to disable spring-data-mongodb autoconfiguration in spring-boot

From Dev

about spring boot how to disable web environment correctly

From Dev

How to disable static content handle in spring-boot?

From Dev

how to selectively disable cache for spring boot (manifest.appcache)

From Dev

How to disable Tomcat session persistence in Spring Boot via Manager pathname?

From Dev

How to disable Spring Boot's autoconfiguration for Apache Velocity?

From Dev

How to disable spring-boot executable jar default log file?

From Dev

How to disable security on management port for Spring Boot app?

From Dev

How to remove/disable Spring boot logo on web browser completely?

From Dev

How to disable default shutdown hook of Hazelcast in spring boot

From Dev

about spring boot how to disable web environment correctly

From Dev

How to disable CSRF for spring boot Actuator URLs for AWS deployment

From Java

Spring Boot - Disable validation logs

From Dev

Spring Boot Social disable ConnectController

From Dev

Spring Boot Disable /error mapping

From Dev

Spring Boot Disable /error mapping

Related Related

  1. 1

    Spring Boot war file on tomcat: errorPageFilter cannot be cast to TomcatEmbeddedServletContainerFactory

  2. 2

    how to disable spring boot HibernateJpaAutoConfiguration

  3. 3

    how to disable spring boot HibernateJpaAutoConfiguration

  4. 4

    How to disable some warnings in Spring Boot

  5. 5

    how to disable spring boot logo in stdout?

  6. 6

    Spring Boot - How to disable @Cacheable during development?

  7. 7

    How to disable Hibernate validation in a Spring Boot project

  8. 8

    How to disable logback ConsoleAppender in Spring Boot

  9. 9

    How to disable security in Spring-Boot 2?

  10. 10

    How to disable `@EnableKafka` in Spring Boot tests?

  11. 11

    How to disable console logging in spring-boot?

  12. 12

    How disable scanning @Configuration class in Spring boot

  13. 13

    How to disable write operation for Jolokia in Spring boot?

  14. 14

    How to disable spring-data-mongodb autoconfiguration in spring-boot

  15. 15

    about spring boot how to disable web environment correctly

  16. 16

    How to disable static content handle in spring-boot?

  17. 17

    how to selectively disable cache for spring boot (manifest.appcache)

  18. 18

    How to disable Tomcat session persistence in Spring Boot via Manager pathname?

  19. 19

    How to disable Spring Boot's autoconfiguration for Apache Velocity?

  20. 20

    How to disable spring-boot executable jar default log file?

  21. 21

    How to disable security on management port for Spring Boot app?

  22. 22

    How to remove/disable Spring boot logo on web browser completely?

  23. 23

    How to disable default shutdown hook of Hazelcast in spring boot

  24. 24

    about spring boot how to disable web environment correctly

  25. 25

    How to disable CSRF for spring boot Actuator URLs for AWS deployment

  26. 26

    Spring Boot - Disable validation logs

  27. 27

    Spring Boot Social disable ConnectController

  28. 28

    Spring Boot Disable /error mapping

  29. 29

    Spring Boot Disable /error mapping

HotTag

Archive