ClassPathResource.getInputStream() has thrown a FileNotFoundException

java.io.FileNotFoundException
Javadoc
at org.springframework.core.io.ClassPathResource.getInputStream
(source)

Typical Exception Messages

  1. Failed to load ApplicationContext
  2. IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
  3. <No message>
  4. IOException parsing XML document from class path resource [beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
  5. IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
  6. Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
  7. class path resource [applicationContext.xml] cannot be opened because it does not exist
  8. IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
  9. Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [cas.properties] cannot be opened because it does not exist
  10. 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

Specific cases

Solution

chinthana, 10 months ago

Use this method to gain access to the ApplicationContext:

@Autowired
private ApplicationContext applicationContext;

Check the source of this solution for more info

External results for this pattern (350)

  1. liyanxivia GitHub1 day ago
    IOException parsing XML document from class path resource [spring-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-context.xml] cannot be opened because it does not exist
    Show stack trace
  2. Unknown authorvia Google Groups1 week ago
    IOException parsing XML document from class path resource [spring/match-converter-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/match-converter-context.xml] cannot be opened because it does not exist
    Show stack trace
  3. MysticRyuujinvia GitHub2 weeks ago
    Failed to parse configuration class [com.ethercamp.harmony.Application]; nested exception is java.io.FileNotFoundException: class path resource [org/ethereum/vm/VMHook.class] cannot be opened because it does not exist
    Show stack trace
  4. solidersvia GitHub2 months ago
    IOException parsing XML document from class path resource [activiti.cfg.xml]; nested exception is java.io.FileNotFoundException: class path resource [activiti.cfg.xml] cannot be opened because it does not exist
    Show stack trace
  5. JiangChen123via GitHub2 months ago
    IOException parsing XML document from class path resource [ureport-core-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [ureport-core-context.xml] cannot be opened because it does not exist
    Show stack trace
  6. monstervia Stack Overflow2 months ago
    Failed to parse configuration class [Application]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/session/data/mongo/config/annotation/web/reactive/ReactiveMongoWebSessionConfiguration.class] cannot be opened because it does not exist
    Show stack trace
  7. Failed to parse configuration class [com.sankuai.xy.safelog.SafelogApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ibatis/plugin/Interceptor.class] cannot be opened because it does not exist
    Show stack trace
  8. Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    Show stack trace
  9. narsivia Stack Overflow3 months ago
    class path resource [einvoice-spring.properties] cannot be opened because it does not exist
    Show stack trace
  10. ericsawlervia GitHub3 months ago
    class path resource [gs://ericstest/my-file.txt] cannot be opened because it does not exist
    Show stack trace