Affects: 6.2.1

It is similar problem what is described in the issue 33972.

After upgrade to Spring boot 3.4.0 (Spring 6.2.0) we sometimes see a BeanCurrentlyInCreationException in our logs after application startup. I upgraded to Spring boot 3.4.1 (with fix from the issue 33972 but BeanCurrentlyInCreationException still pops up from time to time.

My application is Spring gateway using WebFlux.

Unfortunately I cannot reproduce it in the unit or integration tests.

This was working fine in spring 6.1.15 and is broken in 6.2.0 and 6.2.1.

I enable TRACE log messages from classes org.springframework.beans.factory.support.DefaultListableBeanFactory and org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.

2025-01-02 11:21:10.038 [ INFO] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating singleton bean 'braveTracerBridge' in thread "main" while other thread holds singleton lock for other beans [observationRegistry, braveTracing, configure, org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration, braveTracer, braveTracerBridge, defaultTracingObservationHandler]
2025-01-02 11:21:10.038 [DEBUG] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating shared instance of singleton bean 'braveTracerBridge'
2025-01-02 11:21:15.598 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Ignoring factory method [public io.micrometer.tracing.handler.DefaultTracingObservationHandler org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration.defaultTracingObservationHandler(io.micrometer.tracing.Tracer)] of bean 'defaultTracingObservationHandler': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
2025-01-02 11:21:15.604 [TRACE] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'braveTracing'
2025-01-02 11:21:15.604 [DEBUG] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Autowiring by type from bean name 'braveTracer' via factory method to bean named 'braveTracing'
2025-01-02 11:21:15.606 [TRACE] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'braveTracer'
2025-01-02 11:21:15.606 [TRACE] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'braveCurrentTraceContext'
2025-01-02 11:21:15.606 [DEBUG] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Autowiring by type from bean name 'braveTracerBridge' via factory method to bean named 'braveTracer'
2025-01-02 11:21:15.606 [DEBUG] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Autowiring by type from bean name 'braveTracerBridge' via factory method to bean named 'braveCurrentTraceContext'
2025-01-02 11:21:19.756 [TRACE] --- [ntLoopGroup-3-4] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'braveTracerBridge'
2025-01-02 11:21:19.758 [ WARN] --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration': Unsatisfied dependency expressed through method 'setSecurityWebFilterChains' parameter 0: Error creating bean with name 'configure' defined in class path resource [de/fiskal/serviceapi/app/config/WebSecurityConfiguration.class]: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configure' threw exception with message: Error creating bean with name 'observationRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfiguration.class]: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
2025-01-02 11:21:19.758 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'braveTracing': [braveTracer]
2025-01-02 11:21:19.758 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'braveTracer': [braveTracerBridge]
2025-01-02 11:21:20.765 [ WARN] --- [           main] z.r.i.AsyncReporter$BoundedAsyncReporter : Timed out waiting for in-flight spans to send
2025-01-02 11:21:20.767 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean '(inner bean)#7b33deed': [org.springframework.data.mongodb.core.mapping.event.AuditingEntityCallback]
2025-01-02 11:21:20.775 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'reactiveMongoDatabaseFactory': [reactiveMongoTemplate]
2025-01-02 11:21:20.775 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'reactiveMongoTemplate': [tenantRepository]
2025-01-02 11:21:20.775 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'tenantRepository': [addUserHeadersFilter]
2025-01-02 11:21:20.786 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'prometheusMeterRegistry': [mongoMetricsConnectionPoolListener, mongoMetricsCommandListener]
2025-01-02 11:21:20.787 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'mongoMetricsConnectionPoolListener': [mongoMetricsConnectionPoolListenerClientSettingsBuilderCustomizer]
2025-01-02 11:21:20.787 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'mongoMetricsCommandListener': [mongoMetricsCommandListenerClientSettingsBuilderCustomizer]
2025-01-02 11:21:22.802 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'fileWatcher': [sslPropertiesSslBundleRegistrar]
2025-01-02 11:21:22.802 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'reactorResourceFactory': [nettyReactiveWebServerFactory]
2025-01-02 11:21:22.804 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'refreshScope': [legacyContextRefresher]
2025-01-02 11:21:22.805 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory': [org.springframework.context.annotation.internalConfigurationAnnotationProcessor]
2025-01-02 11:21:22.811 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'springBootLoggingLifecycle'
2025-01-02 11:21:22.811 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'lifecycleProcessor'
2025-01-02 11:21:22.814 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15f8701f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,bootstrapImportSelectorConfiguration,org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory,org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor,org.springframework.boot.context.internalConfigurationPropertiesBinder,org.springframework.boot.context.properties.BoundConfigurationProperties,org.springframework.boot.context.properties.EnableConfigurationPropertiesRegistrar.methodValidationExcludeFilter,spring.cloud.config-org.springframework.cloud.bootstrap.config.PropertySourceBootstrapProperties,org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfiguration,keyProperties,environmentDecryptApplicationListener,org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration,configurationPropertiesBeans,configurationPropertiesRebinder,org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,propertySourcesPlaceholderConfigurer]; root of factory hierarchy
2025-01-02 11:21:22.814 [TRACE] --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory': [org.springframework.context.annotation.internalConfigurationAnnotationProcessor]
2025-01-02 11:21:22.845 [ INFO] --- [           main] .s.b.a.l.ConditionEvaluationReportLogger :   Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-01-02 11:21:22.860 [ERROR] --- [           main] o.s.b.SpringApplication                  : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration': Unsatisfied dependency expressed through method 'setSecurityWebFilterChains' parameter 0: Error creating bean with name 'configure' defined in class path resource [de/fiskal/serviceapi/app/config/WebSecurityConfiguration.class]: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configure' threw exception with message: Error creating bean with name 'observationRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfiguration.class]: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:896)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:849)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1441)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1122)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1093)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1030)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)
    at com.app.serviceapi.app.Application.main(Application.java:16)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [de/fiskal/serviceapi/app/config/WebSecurityConfiguration.class]: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configure' threw exception with message: Error creating bean with name 'observationRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfiguration.class]: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1357)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1883)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1847)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeanCollection(DefaultListableBeanFactory.java:1737)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1705)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1580)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1519)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:888)
    ... 22 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configure' threw exception with message: Error creating bean with name 'observationRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfiguration.class]: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:199)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:88)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:168)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    ... 39 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'observationRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfiguration.class]: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1631)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getIfUnique(DefaultListableBeanFactory.java:2434)
    at org.springframework.beans.factory.ObjectProvider.getIfUnique(ObjectProvider.java:167)
    at org.springframework.security.config.annotation.web.reactive.ReactiveObservationConfiguration$1.postProcess(ReactiveObservationConfiguration.java:53)
    at org.springframework.security.config.annotation.web.reactive.ReactiveObservationConfiguration$1.postProcess(ReactiveObservationConfiguration.java:50)
    at org.springframework.security.config.web.server.ServerHttpSecurity$AuthorizeExchangeSpec.configure(ServerHttpSecurity.java:1933)
    at org.springframework.security.config.web.server.ServerHttpSecurity.build(ServerHttpSecurity.java:1716)
    at com.app.serviceapi.app.config.WebSecurityConfiguration.configure(WebSecurityConfiguration.java:40)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:171)
    ... 42 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultTracingObservationHandler' defined in class path resource [org/springframework/boot/actuate/autoconfigure/tracing/MicrometerTracingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'defaultTracingObservationHandler' parameter 0: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:546)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1357)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1890)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1847)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1664)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1580)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.resolveStream(DefaultListableBeanFactory.java:2479)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.orderedStream(DefaultListableBeanFactory.java:2473)
    at org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryConfigurer.asOrderedList(ObservationRegistryConfigurer.java:101)
    at org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryConfigurer.lambda$registerHandlers$0(ObservationRegistryConfigurer.java:78)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.ifAvailable(DefaultListableBeanFactory.java:2403)
    at org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryConfigurer.registerHandlers(ObservationRegistryConfigurer.java:77)
    at org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryConfigurer.configure(ObservationRegistryConfigurer.java:71)
    at org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryPostProcessor.postProcessAfterInitialization(ObservationRegistryPostProcessor.java:69)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1811)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
    ... 59 more
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'braveTracerBridge': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:421)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:282)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1631)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1519)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    ... 84 more

I include whole log from the application.

app.log

Comment From: jhoeller

@marosrojis I've revised this towards on-demand locking for a specific bean when encountering a BeanCurrentlyInCreationException in a non-locked thread. This is available in the latest 6.2.2 snapshot now; please give it an early try if you have the chance (before 6.2.2 becomes generally available on Thursday).

Comment From: marosrojis

@jhoeller I tested my application with 6.2.2-SNAPSHOT. It works well again, good job :) Thank you for your help.

Comment From: jhoeller

Good to hear! Thanks for the immediate feedback, @marosrojis.

Comment From: kakawait

Good to hear! Thanks for the immediate feedback, @marosrojis.

We had quite same issue on several Spring (not spring boot) webapps when migrating from 6.1.x to 6.2.1. The latest 6.2.2-SNAPSHOT was fixing most of them, but we still facing issue on one of them.

org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dataSource': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency

Should I create a new issue @jhoeller or simply add you more information (because I'm aware that above log is unhelpful like that) on this thread (starting tomorrow 16jan GMT+1)?

Comment From: anabright

We're also having bean dependency issues on startup after upgrading from Spring 6.1.14 to 6.2.2

14:29:56.346 [RMI TCP Connection(2)-127.0.0.1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '/processorBean': Unsatisfied dependency expressed through field 'exportManager': Error creating bean with name 'userExportManager': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1445) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:307) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1122) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1093) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1030) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.2.jar:6.2.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.2.jar:6.2.2]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:394) ~[spring-web-6.2.2.jar:6.2.2]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:274) ~[spring-web-6.2.2.jar:6.2.2]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:126) ~[spring-web-6.2.2.jar:6.2.2]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4006) ~[catalina.jar:10.1.33]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4436) ~[catalina.jar:10.1.33]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) ~[catalina.jar:10.1.33]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599) ~[catalina.jar:10.1.33]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571) ~[catalina.jar:10.1.33]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654) ~[catalina.jar:10.1.33]
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1796) ~[catalina.jar:10.1.33]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:264) ~[tomcat-coyote.jar:10.1.33]
    at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:814) ~[?:?]
    at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802) ~[?:?]
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:422) ~[catalina.jar:10.1.33]
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:376) ~[catalina.jar:10.1.33]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:264) ~[tomcat-coyote.jar:10.1.33]
    at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:814) ~[?:?]
    at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802) ~[?:?]
    at java.management/com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:472) ~[?:?]
    at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1472) ~[?:?]
    at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1310) ~[?:?]
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) ~[?:?]
    at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1412) ~[?:?]
    at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) ~[?:?]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) ~[?:?]
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[?:?]
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[?:?]
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) [?:?]
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[?:?]
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587) ~[?:?]
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828) ~[?:?]
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705) ~[?:?]
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) [?:?]
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704) [?:?]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
    at java.base/java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'userExportManager': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:439) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:284) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1631) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1519) ~[spring-beans-6.2.2.jar:6.2.2]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785) ~[spring-beans-6.2.2.jar:6.2.2]
    ... 64 more

Comment From: jhoeller

As of 6.2.2, this kind of issue can only happen if another thread concurrently initializes common beans while the main thread tries to initialize all singletons in the preInstantiateSingletons phase. In general, such uncontrolled concurrent startup is not expected in web applications. Other threads are supposed to wait before hitting the context until the ContextLoaderListener has finished its initialization step. Before 6.2, this might implicitly have happened due to waiting for the singleton lock but it really should have been guarded by a custom lock even before.

You'll need to find out which other threads hit the context there and make them wait until the context has been fully initialized. Or at least, make sure that the affected beans (such as 'userExportManager' in your case) are initialized early enough - namely, before those other threads start creating beans that depend on those common beans. The startup order can be enforced through corresponding @DependsOn declarations between those beans, for example from some bean that internally starts a thread (that in turn triggers the creation of other beans) to the common beans that need to be created first.