Skip to content

Web application could not be started as there was no org.ReactiveWebServerFactory bean defined can be thrown due to missing condition on NettyReactiveWebServerAutoConfiguration #49693

@evan-mc

Description

@evan-mc

Problem
I am in the process of upgrading a spring webflux application from Spring Boot 3 to Spring Boot 4. After upgrading, I encounter the following error at startup:

Web application could not be started as there was no org.springframework.boot.web.server.reactive.ReactiveWebServerFactory bean defined in the context.

I was able to create a minimally reproducible example.
Main Application / parent class:

@SpringBootApplication
public class ApplicationConfig {
    public static void main(String[] args) {
       new SpringApplicationBuilder()
               .parent(ApplicationConfig.class).web(WebApplicationType.NONE)
               .child(ChildConfig.class).web(WebApplicationType.REACTIVE).main(ChildConfig.class)
               .run(args);
    }
}

Child config class:

@Configuration
@EnableAutoConfiguration
public class ChildConfig {
}

Fix
I was able to fix this by excluding the auto-configuration for the web server in the parent config, like so:
@SpringBootApplication(exclude = {NettyReactiveWebServerAutoConfiguration.class})

This is just a temporary workaround, however. In Spring Boot 3, ReactiveWebServerFactoryAutoConfiguration used @ConditionalOnWebApplication(type = Type.REACTIVE). I believe this annotation should be reintroduced for Spring Boot 4's NettyReactiveWebServerAutoConfiguration

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions