org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0:

Spring JIRA | David Harrigan | 6 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I seem to have found a regression between 3.0.5.RELEASE and 3.1.0.M2. Here is the offending code: {code:title=DaoFactory.java} @Component("daoFactory") public class DaoFactory { @Autowired private ApplicationContext applicationContext; public TestDao getTestDao() { return applicationContext.getBean("test", TestDaoImpl.class); } @Repository("test") public class TestDaoImpl extends AbstractDao<Model> implements TestDao { public TestDaoImpl() { super(Model.class); } @Override public Model create() { return null; } } } {code} If I run this via a simple unit test: {code:title=DaoFactoryTest.java} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:applicationContext-testing.xml") public class DaoFactoryTest { private DaoFactory daoFactory; @Test public void assertGetArticleDao() { final TestDao testDao = daoFactory.getTestDao(); assertNotNull(testDao); } @Resource public void setDaoFactory(final DaoFactory daoFactory) { this.daoFactory = daoFactory; } } {code} I obtain this error in 3.1.0.M2: {noformat} java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:181) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.runners.ParentRunner.run(ParentRunner.java:236) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) [.cp/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) ~[spring-context-3.1.0.M2.jar:3.1.0.M2] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) ~[spring-context-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:73) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:128) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:172) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] ... 24 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] ... 37 common frames omitted Caused by: java.lang.NoSuchMethodException: X.X.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at java.lang.Class.getConstructor0(Class.java:2706) ~[na:1.6.0_25] at java.lang.Class.getDeclaredConstructor(Class.java:1985) ~[na:1.6.0_25] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] ... 38 common frames omitted {noformat} Whereas, in Spring 3.0.5.RELEASE, I get this: {noformat} org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0: at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:269) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) at X.X.common.domain.dao.impl.DaoFactory.getTestDao(DaoFactory.java:21) at X.X.common.domain.dao.impl.DaoFactoryTest.assertGetArticleDao(DaoFactoryTest.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {noformat} In the Inner Class, you can clearly see that there is a default constructor (which calls to a super which has a default constructor). =david=

    Spring JIRA | 6 years ago | David Harrigan
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0:
  2. 0

    I seem to have found a regression between 3.0.5.RELEASE and 3.1.0.M2. Here is the offending code: {code:title=DaoFactory.java} @Component("daoFactory") public class DaoFactory { @Autowired private ApplicationContext applicationContext; public TestDao getTestDao() { return applicationContext.getBean("test", TestDaoImpl.class); } @Repository("test") public class TestDaoImpl extends AbstractDao<Model> implements TestDao { public TestDaoImpl() { super(Model.class); } @Override public Model create() { return null; } } } {code} If I run this via a simple unit test: {code:title=DaoFactoryTest.java} @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:applicationContext-testing.xml") public class DaoFactoryTest { private DaoFactory daoFactory; @Test public void assertGetArticleDao() { final TestDao testDao = daoFactory.getTestDao(); assertNotNull(testDao); } @Resource public void setDaoFactory(final DaoFactory daoFactory) { this.daoFactory = daoFactory; } } {code} I obtain this error in 3.1.0.M2: {noformat} java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:181) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) [junit-dep-4.8.2.jar:na] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.junit.runners.ParentRunner.run(ParentRunner.java:236) [junit-dep-4.8.2.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) [spring-test-3.1.0.M2.jar:3.1.0.M2] at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) [.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) [.cp/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) ~[spring-context-3.1.0.M2.jar:3.1.0.M2] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) ~[spring-context-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:73) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:128) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:172) ~[spring-test-3.1.0.M2.jar:3.1.0.M2] ... 24 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] ... 37 common frames omitted Caused by: java.lang.NoSuchMethodException: X.X.domain.dao.impl.DaoFactory$TestDaoImpl.<init>() at java.lang.Class.getConstructor0(Class.java:2706) ~[na:1.6.0_25] at java.lang.Class.getDeclaredConstructor(Class.java:1985) ~[na:1.6.0_25] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67) ~[spring-beans-3.1.0.M2.jar:3.1.0.M2] ... 38 common frames omitted {noformat} Whereas, in Spring 3.0.5.RELEASE, I get this: {noformat} org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0: at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:269) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) at X.X.common.domain.dao.impl.DaoFactory.getTestDao(DaoFactory.java:21) at X.X.common.domain.dao.impl.DaoFactoryTest.assertGetArticleDao(DaoFactoryTest.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {noformat} In the Inner Class, you can clearly see that there is a default constructor (which calls to a super which has a default constructor). =david=

    Spring JIRA | 6 years ago | David Harrigan
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0:
  3. 0

    GWT RequestFactory Error when firing request : org.springframework.beans.factory.NoSuchBeanDefinitionException

    Google Groups | 5 years ago | Radu Chilom
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.aievas.star.shared.services.StarRequestFactory$RaduRequestContext] is defined: expected single bean but found 0:
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    No unique bean of type is defined: expected single bean but found 0:

    Stack Overflow | 3 years ago | bubai
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.test.ComponentConsumer] is defined: expected single bean but found 0:
  6. 0

    GWT RequestFactory Error when firing request : org.springframework.beans.factory.NoSuchBeanDefinitionException

    Stack Overflow | 5 years ago | Radu Chilom
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.base.star.shared.services.StarRequestFactory$RaduRequestContext] is defined: expected single bean but found 0:

  1. Gatgeagent 4 times, last 7 months ago
  2. Pilleo 6 times, last 8 months ago
  3. qavid 2 times, last 11 months ago
  4. MrMonkey 3 times, last 1 year ago
  5. iferca 1 times, last 3 months ago
4 more registered users
19 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.factory.NoSuchBeanDefinitionException

    No unique bean of type [X.X.common.domain.dao.impl.DaoFactory$TestDaoImpl] is defined: expected single bean but found 0:

    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean()
  2. Spring Beans
    DefaultListableBeanFactory.getBean
    1. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:269)
    1 frame
  3. Spring Context
    AbstractApplicationContext.getBean
    1. org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
    1 frame
  4. X.X.common
    DaoFactoryTest.assertGetArticleDao
    1. X.X.common.domain.dao.impl.DaoFactory.getTestDao(DaoFactory.java:21)
    2. X.X.common.domain.dao.impl.DaoFactoryTest.assertGetArticleDao(DaoFactoryTest.java:22)
    2 frames
  5. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  6. JUnit
    InvokeMethod.evaluate
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    4 frames
  7. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    4 frames
  8. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    6 frames
  9. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    2 frames
  10. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    1 frame
  11. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    1 frame
  12. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    1 frame
  13. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames