0

I'm comming with popular erorr which is: class path resource [db/file.xml] cannot be resolved to URL because it does not exist. I'm using Spring Boot with version 1.3.5.RELEASE and I'm trying to use liquibase with it. My project is multimodule. In module A I have Main class within which I run whole application. In module B under (path from repository root) B/src/main/resources/db/file.xml I have an xml with with changesets. In module A in application.properties I have this configuration:

...
liquibase.change-log=classpath:db/db.changelog.project-master.xml

spring.jpa.hibernate.ddl-auto=none
spring.h2.console.enabled=true

db/db.changelog.project-master.xml is file within module A.

Under this file (db.changelog.project-master.xml) I have include that shoudl include this changesets from another module (module B)

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

    <include file="db/file.xml" />
    
</databaseChangeLog>

I have tried also with <include file="classpath:db/file.xml" />.Unfortuantely when I run application from module A I get:

Caused by: liquibase.exception.ChangeLogParseException: Error Reading Migration File: class path resource [db/file.xml] cannot be resolved to URL because it does not exist
    at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:112)
    at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:17)
    at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:404)
    at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:267)
    ... 25 more
Caused by: java.io.FileNotFoundException: class path resource [db/file.xml] cannot be resolved to URL because it does not exist

Could you tell me what is wrong?

1 Answer 1

0

I'm not sure about the answer but I think the path you are specifying "<include file="db/file.xml" />" will search for the file inside "db" directory of Module A and will fail to find one. Can you try specifying the absolute path for "file.xml" while you are including it in the master changelog file.

Let's consider below is your project structure:

--project
---------module A
         -src
            -main
             - resources
              - db
               - db.changelog.project-master.xml
---------module B
          -src
             -main
              - resources
               - db
                - file.xml

The master changelog file won't be able to find "file.xml" inside "db" directory of Module A. I think providing absolute path of file.xml could prove to be helpful.

<include file="B/src/main/db/file.xml" />

or may be try providing path for "file.xml" relative to the location of master changelog file.

Pardon if my understanding of your question was wrong.

Cheers!!

1
  • Can you paste the project structure here?(or Confirm if the above specified is the same) IT will help us understand the structure/placement of directories/files and would be helpful in reproducing this problem at my end. Mar 8, 2021 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.