java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist

JIRA | Klaus Bayrhammer | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    We are heavily using SpringLiquibase for keeping our executing our changesets. When we are starting our spring context on a server we get a FileNotFoundException per SpringLiquibase-Instance we are starting. Although the exception occured, the liquibase updates are executed without problems. Nevertheless the exception and the stacktrace in the log is quite annoying so we tried to get rid of it. Unfortunately the exception-logging uses {{liquibase.logging.LogFactory#getLog()}} which specifies one LoggerName (liquibase) for all liquibase-logs. So its not possible for us to set the logging level for liquibase.integration.spring.SpringLiquibase to ERROR without loosing all the other liquibase WARN logs. See the attached stacktrace below. You can reproduce the problem with the following [spring-boot repo|https://github.com/klausbayrhammer/spring-boot/tree/fileNotFoundException/spring-boot-samples/spring-boot-sample-liquibase]. You just have to execute * {{mvn clean package assembly:single}} * {{java -jar target/spring-boot-sample-liquibase-1.3.0.BUILD-SNAPSHOT-jar-with-dependencies.jar}} {noformat} WARNING 23/04/15 15:05: liquibase: Error initializing SpringLiquibase java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:77) at liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22) at liquibase.resource.ClassLoaderResourceAccessor.<init>(ClassLoaderResourceAccessor.java:18) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:67) at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:396) at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:357) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:315) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:766) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:812) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:958) at org.springframework.boot.SpringApplication.run(SpringApplication.java:947) at sample.liquibase.SampleLiquibaseApplication.main(SampleLiquibaseApplication.java:33) {noformat}

    JIRA | 2 years ago | Klaus Bayrhammer
    java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
  2. 0

    We are heavily using SpringLiquibase for keeping our executing our changesets. When we are starting our spring context on a server we get a FileNotFoundException per SpringLiquibase-Instance we are starting. Although the exception occured, the liquibase updates are executed without problems. Nevertheless the exception and the stacktrace in the log is quite annoying so we tried to get rid of it. Unfortunately the exception-logging uses {{liquibase.logging.LogFactory#getLog()}} which specifies one LoggerName (liquibase) for all liquibase-logs. So its not possible for us to set the logging level for liquibase.integration.spring.SpringLiquibase to ERROR without loosing all the other liquibase WARN logs. See the attached stacktrace below. You can reproduce the problem with the following [spring-boot repo|https://github.com/klausbayrhammer/spring-boot/tree/fileNotFoundException/spring-boot-samples/spring-boot-sample-liquibase]. You just have to execute * {{mvn clean package assembly:single}} * {{java -jar target/spring-boot-sample-liquibase-1.3.0.BUILD-SNAPSHOT-jar-with-dependencies.jar}} {noformat} WARNING 23/04/15 15:05: liquibase: Error initializing SpringLiquibase java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:77) at liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22) at liquibase.resource.ClassLoaderResourceAccessor.<init>(ClassLoaderResourceAccessor.java:18) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:67) at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:396) at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:357) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:315) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:766) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:812) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:958) at org.springframework.boot.SpringApplication.run(SpringApplication.java:947) at sample.liquibase.SampleLiquibaseApplication.main(SampleLiquibaseApplication.java:33) {noformat}

    JIRA | 2 years ago | Klaus Bayrhammer
    java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
  3. 0

    I'm using SpringLiquibase. Defined like: {code} final SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDefaultSchema("users"); springLiquibase.setDataSource(dataSource); springLiquibase.setChangeLog("classpath:changelog-users.xml"); springLiquibase.setResourceLoader(new DefaultResourceLoader()); springLiquibase.afterPropertiesSet(); {code} Also I have jar file mysql.jar, which has structure like: {code} mysql.jar - src - changelog-users.xml {code} And then I'm running this jar via {code}java -jar mysql.jar --init {code} All this stuff finishes with exception {code} java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:178) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:74) at liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:64) at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:388) at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:349) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:300) {code} Which completely fail liquibase provisioning. May help: version 3.1.1 works fine as well as 2.0.5, which I used before.

    JIRA | 2 years ago | Sergey
    java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I'm using SpringLiquibase. Defined like: {code} final SpringLiquibase springLiquibase = new SpringLiquibase(); springLiquibase.setDefaultSchema("users"); springLiquibase.setDataSource(dataSource); springLiquibase.setChangeLog("classpath:changelog-users.xml"); springLiquibase.setResourceLoader(new DefaultResourceLoader()); springLiquibase.afterPropertiesSet(); {code} Also I have jar file mysql.jar, which has structure like: {code} mysql.jar - src - changelog-users.xml {code} And then I'm running this jar via {code}java -jar mysql.jar --init {code} All this stuff finishes with exception {code} java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:178) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:74) at liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:64) at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:388) at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:349) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:300) {code} Which completely fail liquibase provisioning. May help: version 3.1.1 works fine as well as 2.0.5, which I used before.

    JIRA | 2 years ago | Sergey
    java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
  6. 0

    LocalContainerEntityManagerFactoryBean with Karaf, Spring, and JPA

    Stack Overflow | 2 years ago | Randy Leonard
    javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
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 [] cannot be resolved to URL because it does not exist

    at org.springframework.core.io.ClassPathResource.getURL()
  2. Spring Core
    ClassPathResource.getURL
    1. org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187)
    1 frame
  3. Liquibase Core
    SpringLiquibase.afterPropertiesSet
    1. liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:77)
    2. liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22)
    3. liquibase.resource.ClassLoaderResourceAccessor.<init>(ClassLoaderResourceAccessor.java:18)
    4. liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:67)
    5. liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:396)
    6. liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:357)
    7. liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:315)
    7 frames
  4. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    5. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    6. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    7. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    8. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    9. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:766)
    9 frames
  5. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:812)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521)
    2 frames
  6. Spring Boot
    SpringApplication.run
    1. org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
    2. org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    3. org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
    4. org.springframework.boot.SpringApplication.run(SpringApplication.java:947)
    4 frames
  7. sample.liquibase
    SampleLiquibaseApplication.main
    1. sample.liquibase.SampleLiquibaseApplication.main(SampleLiquibaseApplication.java:33)
    1 frame