java.lang.IllegalStateException: Failed to load ApplicationContext

Spring JIRA | David Turanski | 6 years ago
  1. 0

    Given public class Outer { public static class Inner { } } <bean class="Outer.Inner"/> works in fine in Spring 3.0. In fact STS code completion provides the '.'. <bean class="Outer$Inner"/> works in 3.0 and 3.1 In the first case Spring 3.1 throws the following exception: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) 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) Caused by: java.lang.IllegalStateException: Could not create MetadataReader for class Outer.Inner at org.springframework.context.annotation.ConfigurationClassPostProcessor.isFeatureConfiguration(ConfigurationClassPostProcessor.java:286) at org.springframework.context.annotation.ConfigurationClassPostProcessor.retrieveFeatureConfigurationBeans(ConfigurationClassPostProcessor.java:253) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processFeatureConfigurationClasses(ConfigurationClassPostProcessor.java:210) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:203) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:176) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304) ... 24 more Caused by: java.io.FileNotFoundException: class path resource [Outer/Inner.class] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:45) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76) at org.springframework.context.annotation.ConfigurationClassPostProcessor.isFeatureConfiguration(ConfigurationClassPostProcessor.java:279) ... 34 more

    Spring JIRA | 6 years ago | David Turanski
    java.lang.IllegalStateException: Failed to load ApplicationContext
  2. 0

    Given public class Outer { public static class Inner { } } <bean class="Outer.Inner"/> works in fine in Spring 3.0. In fact STS code completion provides the '.'. <bean class="Outer$Inner"/> works in 3.0 and 3.1 In the first case Spring 3.1 throws the following exception: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) 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) Caused by: java.lang.IllegalStateException: Could not create MetadataReader for class Outer.Inner at org.springframework.context.annotation.ConfigurationClassPostProcessor.isFeatureConfiguration(ConfigurationClassPostProcessor.java:286) at org.springframework.context.annotation.ConfigurationClassPostProcessor.retrieveFeatureConfigurationBeans(ConfigurationClassPostProcessor.java:253) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processFeatureConfigurationClasses(ConfigurationClassPostProcessor.java:210) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:203) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:176) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304) ... 24 more Caused by: java.io.FileNotFoundException: class path resource [Outer/Inner.class] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:45) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76) at org.springframework.context.annotation.ConfigurationClassPostProcessor.isFeatureConfiguration(ConfigurationClassPostProcessor.java:279) ... 34 more

    Spring JIRA | 6 years ago | David Turanski
    java.lang.IllegalStateException: Failed to load ApplicationContext
  3. 0

    Handle the use of @ComponentScan in the default package more gracefully

    GitHub | 2 years ago | wilkinsona
    org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [Application]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] cannot be opened because it does not exist
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    An app that depends on spring-boot-starter-jersey and spring-boot-starter-data-jpa fails to start with a FileNotFoundException

    GitHub | 2 years ago | wilkinsona
    org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [demo.Stackoverflow27915560Application]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
  6. 0

    App that depends on spring-security-core, but not spring-security-config, fails to start

    GitHub | 2 years ago | wilkinsona
    org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: ; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/security/config/annotation/authentication/configurers/GlobalAuthenticationConfigurerAdapter.class] cannot be opened because it does not exist

  1. wendellpereira 4 times, last 3 months ago
  2. Shadd518 2 times, last 4 months ago
  3. kid 2 times, last 8 months ago
15 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.io.FileNotFoundException

    class path resource [Outer/Inner.class] cannot be opened because it does not exist

    at org.springframework.core.io.ClassPathResource.getInputStream()
  2. Spring Core
    SimpleMetadataReaderFactory.getMetadataReader
    1. org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    2. org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:45)
    3. org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
    4. org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
    4 frames
  3. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.annotation.ConfigurationClassPostProcessor.isFeatureConfiguration(ConfigurationClassPostProcessor.java:279)
    2. org.springframework.context.annotation.ConfigurationClassPostProcessor.retrieveFeatureConfigurationBeans(ConfigurationClassPostProcessor.java:253)
    3. org.springframework.context.annotation.ConfigurationClassPostProcessor.processFeatureConfigurationClasses(ConfigurationClassPostProcessor.java:210)
    4. org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(ConfigurationClassPostProcessor.java:203)
    5. org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:176)
    6. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604)
    7. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437)
    7 frames
  4. Spring TestContext
    SpringJUnit4ClassRunner$1.runReflectiveCall
    1. org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
    2. org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
    3. org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
    4. org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
    5. org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
    6. org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    7. org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
    8. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
    9. org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
    9 frames
  5. JUnit
    ReflectiveCallable.run
    1. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    1 frame
  6. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
    2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    2 frames
  7. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    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
  8. 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
  9. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    1 frame
  10. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    1 frame
  11. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    1 frame
  12. 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