ClassPathResource.getInputStream() has thrown a FileNotFoundException

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

Typical Exception Messages

  1. class path resource [applicationContext.xml] cannot be opened because it does not exist
  2. class path resource [Beans.xml] cannot be opened because it does not exist
  3. class path resource [beans.xml] cannot be opened because it does not exist
  4. class path resource [cas.properties] cannot be opened because it does not exist
  5. class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] cannot be opened because it does not exist
  6. class path resource [org/springframework/security/config/annotation/authentication/configurers/GlobalAuthenticationConfigurerAdapter.class] cannot be opened because it does not exist
  7. class path resource [spring.xml] cannot be opened because it does not exist
  8. class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
  9. class path resource [datasource.properties] cannot be opened because it does not exist
  10. class path resource [application-context.xml] cannot be opened because it does not exist

Specific cases

Solution

chinthana, 8 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 (348)

  1. JiangChen123via GitHub2 weeks ago
    class path resource [ureport-core-context.xml] cannot be opened because it does not exist
    Show stack trace
  2. monstervia Stack Overflow2 weeks ago
    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
  3. class path resource [org/apache/ibatis/plugin/Interceptor.class] cannot be opened because it does not exist
    Show stack trace
  4. class path resource [datasource.properties] cannot be opened because it does not exist
    Show stack trace
  5. narsivia Stack Overflow4 weeks ago
    class path resource [einvoice-spring.properties] cannot be opened because it does not exist
    Show stack trace
  6. ericsawlervia GitHub1 month ago
    class path resource [gs://ericstest/my-file.txt] cannot be opened because it does not exist
    Show stack trace
  7. class path resource [spring.xml] cannot be opened because it does not exist
    Show stack trace
  8. Sintendovia GitHub1 month ago
    class path resource [s3://bucket/file.txt] cannot be opened because it does not exist
    Show stack trace
  9. oshiryaevavia GitHub1 month ago
    class path resource [comcompanysales/web-spring.xml] cannot be opened because it does not exist
    Show stack trace
  10. oshiryaevavia GitHub1 month ago
    class path resource [comcompany] cannot be opened because it does not exist
    Show stack trace