I am trying to create my own ErrorWebExceptionHandler
in Spring Boot 2 by extending the default one but my application fails to start with the following message:
Caused by: java.lang.IllegalArgumentException: Property 'messageWriters' is required
at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.afterPropertiesSet(AbstractErrorWebExceptionHandler.java:214) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
My handler (Kotlin code):
@Component
@Order(-2)
class SampleErrorWebExceptionHandler(
errorAttributes: ErrorAttributes?,
resourceProperties: ResourceProperties?,
errorProperties: ErrorProperties?,
applicationContext: ApplicationContext?
) : DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, applicationContext) {
override fun logError(request: ServerRequest, errorStatus: HttpStatus) {
// do something
}
}
What could be the cause?
messageWriters
andmessageReaders
and it is working now, thanks! – Brickwork