Skip to content

BeanCreationNotAllowedException during shutdown #3005

Closed
@mlichtblau

Description

@mlichtblau

In what version(s) of Spring AMQP are you seeing this issue?

3.1.7

Describe the bug

During shutdown of the application an exception is thrown.
I see the two expected log messages:

Mar 08 09:43:29.299
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
Waiting for workers to finish.

Mar 08 09:43:29.487
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
Successfully waited for workers to finish.

but aftewards I see this exception:

Mar 08 09:43:29.989
Exception in thread "rabbitListenerExecutor1" org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'refreshEventListener': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:265)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:222)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:145)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:452)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:385)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.killOrRestart(SimpleMessageListenerContainer.java:1531)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1408)

Sometimes I also see beans named startupTimeMetrics or delegatingApplicationListener that cannot be created during shutdown.

Is it intentional that during shutdown phase the events are still published?

To Reproduce

Not sure what exactly causes the issue now.

Expected behavior

No exception should be thrown during shutdown.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions