Skip to content

NoSuchBeanDefinitionException with starter-web, starter-webflux and spring.main.web-application-type=reactive #13977

@kklorenzotesta

Description

@kklorenzotesta

Spring boot version: 2.0.4.RELEASE
Java versione: 9.0.4

I'm trying to create a project with both spring-boot-starter-web and spring-boot-starter-webflux. If in my application.properties I declare spring.main.web-application-type=reactive then at runtime a bean of type ErrorAttributes is missing and this exception is thrown:

2018-08-01 21:47:48.854  WARN 17460 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpHandler' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration$AnnotationConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.server.reactive.HttpHandler]: Factory method 'httpHandler' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.web.server.adapter.WebHttpHandlerBuilder$SortedBeanContainer': Unsatisfied dependency expressed through method 'setExceptionHandlers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'errorWebExceptionHandler' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.class]: Unsatisfied dependency expressed through method 'errorWebExceptionHandler' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.web.reactive.error.ErrorAttributes' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2018-08-01 21:47:48.862  INFO 17460 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-08-01 21:47:49.022 ERROR 17460 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method errorWebExceptionHandler in org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration required a bean of type 'org.springframework.boot.web.reactive.error.ErrorAttributes' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.boot.web.reactive.error.ErrorAttributes' in your configuration.

To replicate the issue I attached a minimal gradle project:
error-attribute.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions