java.lang.IllegalStateException: Failed to load ApplicationContext

Spring JIRA | David Harrigan | 5 years ago
  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 | 5 years ago | David Harrigan
    java.lang.IllegalStateException: Failed to load ApplicationContext
  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 | 5 years ago | David Harrigan
    java.lang.IllegalStateException: Failed to load ApplicationContext
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    NoSuchMethodException when using Spring ThreadPoolTaskExecutor

    Stack Overflow | 2 years ago | Omer
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adSyncTaskPool' defined in URL [jar:file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ad-mgmt/WEB-INF/lib/component-stats-sync-impl2-0.0.1-SNAPSHOT.jar!/me/somesome/task/SyncTaskPool.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [me.somesome.task.SyncTaskPool]: No default constructor found; nested exception is java.lang.NoSuchMethodException: me.somesome.task.SyncTaskPool.&lt;init&gt;() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  5. 0

    Spring Constructor @Autowired and @Qualifier fails

    Stack Overflow | 3 years ago | Cory Kendall
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GreatBean' defined in class path resource [config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [mypackage.MyCoolClass]: No default constructor found; nested exception is java.lang.NoSuchMethodException: mypackage.MyCoolClass.&lt;init&gt;()

  1. ruifung 1 times, last 3 months ago
  2. serious2monkeys 17 times, last 4 months ago
  3. empt-ak 1 times, last 1 month ago
  4. Luka 12 times, last 2 months ago
  5. andyglick 28 times, last 2 months ago
8 more registered users
47 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. java.lang.NoSuchMethodException

    X.X.domain.dao.impl.DaoFactory$TestDaoImpl.<init>()

    at java.lang.Class.getConstructor0()
  2. Java RT
    Class.getDeclaredConstructor
    1. java.lang.Class.getConstructor0(Class.java:2706)[na:1.6.0_25]
    2. java.lang.Class.getDeclaredConstructor(Class.java:1985)[na:1.6.0_25]
    2 frames
  3. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    5. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    6. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    7. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    8. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    9. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    10. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)[spring-beans-3.1.0.M2.jar:3.1.0.M2]
    10 frames
  4. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)[spring-context-3.1.0.M2.jar:3.1.0.M2]
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)[spring-context-3.1.0.M2.jar:3.1.0.M2]
    2 frames
  5. Spring TestContext
    SpringJUnit4ClassRunner$1.runReflectiveCall
    1. org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:73)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    2. org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:128)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    3. org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:172)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    4. org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    5. org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    6. org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    7. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    8. org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    8 frames
  6. JUnit
    ReflectiveCallable.run
    1. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)[junit-dep-4.8.2.jar:na]
    1 frame
  7. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    2 frames
  8. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)[junit-dep-4.8.2.jar:na]
    2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)[junit-dep-4.8.2.jar:na]
    3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)[junit-dep-4.8.2.jar:na]
    4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)[junit-dep-4.8.2.jar:na]
    5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)[junit-dep-4.8.2.jar:na]
    6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)[junit-dep-4.8.2.jar:na]
    6 frames
  9. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    2 frames
  10. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:236)[junit-dep-4.8.2.jar:na]
    1 frame
  11. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)[spring-test-3.1.0.M2.jar:3.1.0.M2]
    1 frame
  12. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)[.cp/:na]
    1 frame
  13. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)[.cp/:na]
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)[.cp/:na]
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)[.cp/:na]
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)[.cp/:na]
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)[.cp/:na]
    5 frames