For me this was fixed by explicitly starting the Spring application context:
ConfigurableApplicationContext applicationContext = SpringApplication.run(DemoApplication.class, args); applicationContext.start();
See this comment from RootNamespaceAutoConfiguration
:
// It needs to listed on ContextStartedEvent, not ContextRefreshedEvent.
// Using ContextRefreshedEvent will cause start of workers early, during the context
// initialization
// and potentially incorrect order of bean initialization.
// Refresh event can also be fired multiple times during the context initialization.
// For this listener to ever work, Spring context needs to be actually started.
// Note that a lot of online samples for Spring don't start the context at all:
// https://stackoverflow.com/questions/48099355/contextstartedevent-not-firing-in-custom-listener