Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating bean with name and Singleton bean creation not allowed

Tags:

java

spring

I am getting the following exception when I execute the code via JUnit Test Case

org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'somarFactory': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

Could someone advise what might be the issues?

like image 355
Kathir Avatar asked Feb 22 '13 05:02

Kathir


People also ask

How do I resolve BeanCreationException in Spring?

To diagnose this type of issue, we'll first make sure the bean is declared: either in an XML configuration file using the <bean /> element. or in a Java @Configuration class via the @Bean annotation. or is annotated with @Component, @Repository, @Service, @Controller, and classpath scanning is active for that package.

Is @bean singleton by default?

By default, the scope of a bean is a singleton.

What is BeanCreationException?

BeanCreationException. . This means that Spring found a bean to create, but was unable to fulfill the dependencies needed to create this this Spring bean.

Can not create bean Spring?

There could be numerous reasons why Spring could not able to create a bean with name X, but clue always lies on the detailed stack trace. This error always has some underlying cause e.g. a ClassNotFoundException or a NoClassDefFoundError, which potentially signal a missing JAR file in the classpath.


1 Answers

Check if you have more than one tomcat's instance.
if this is your case, shutdown all instance then open one and only one instance.
I hope that will help you

like image 149
Kadiri Avatar answered Sep 22 '22 12:09

Kadiri