Specifying files by absolute path was removed in Liquibase 4.0
Asked Answered
L

8

13

I am getting the following liquibase error when I run my Spring Boot application:

Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.

Here is the class path in application.yaml:

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

I also tried:

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

Here is folder structure:

enter image description here

Changlog master:

<?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.5.xsd">

    <include file="db-changelog-1.0.xml"/>
</databaseChangeLog>
Longs answered 21/8, 2021 at 16:28 Comment(1)
It is a known issue and yet not found a resolve. they advice to use version 3.5 github.com/liquibase/liquibase/issues/1277Supat
D
3

Looks like this was fixed in v4.4.3

Destined answered 24/8, 2021 at 12:40 Comment(4)
I still have it on ubuntu v4.4.3. Are you sure?Factorage
still existing on 4.6.1Cumber
Also still existing on 4.9.1Uranous
Still in 4.11.0Gyimah
C
4

I got this issue when putting the changelog files outside the resources folder, but if I include them under resources/db/changelog, then it would work fine with setting the bellow config.

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

Tested under 4.6.2

Carduaceous answered 21/12, 2021 at 0:50 Comment(2)
This solution worked for me as well with 4.6.2Manriquez
Issue with this is if the file is added to multiple jars with maven-remote-resources for exampleDramatics
D
3

Looks like this was fixed in v4.4.3

Destined answered 24/8, 2021 at 12:40 Comment(4)
I still have it on ubuntu v4.4.3. Are you sure?Factorage
still existing on 4.6.1Cumber
Also still existing on 4.9.1Uranous
Still in 4.11.0Gyimah
U
3

This is still an open issue unfortunately. See 2281.

Uranous answered 28/5, 2022 at 8:54 Comment(0)
A
2

As explained here

How the Liquibase classpath worked before version 4.0

Before version 4.0, one of the default locations Liquibase added to the classpath was the root directory in your filesystem (/). The change caused issues because of a machine-dependent changelog path, such as /home/my-user/projects/liquibase/changelog.xml, found under the / directory. This way, Liquibase uses the given path as part of the changeset identifier stored in the DATABASECHANGELOG table, and when you run Liquibase from /home/other-user/projects/liquibase/changelog.xml, Liquibase sees it as a different changelog and tries to rerun all the previously run changesets.

To prevent identification issues from happening, a / was removed as a default part of the classpath. How the Liquibase classpath works in 4.0 and later versions

Starting with Liquibase 4.0, the root directory (/) is no longer a default part of the classpath because of the issue mentioned in the previous section.

...

The message "Please use a relative path or add '/' to the classpath parameter." refers to the root directory '/', and does not mean to add a slash to the start of your classpath path. Afaik, classpath:x and classpath:/x are the same.

Also, the message appears when the master changelog is not found, for whatever reason, so also a typo can cause this message. It's only a hint telling you that it might not be found because the file is not on the classpath, because they removed the root directory from the classpath, but it could also not be found because you specified the wrong path (I just did that).

To configure it correctly, the master changelog must be on the Liquibase classpath. In Spring Boot, the Liquibase classpath is set to the application's classpath, i.e. you can use src/main/resources.

Tl;dr: When your file is src/main/resources/db/changelog/db.changelog-master.xml use spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml

I don't know, whether there was or is a bug in regards to that with certain Liquibase versions, but that's how it's supposed to work, anyway.

Antagonism answered 21/5, 2022 at 21:44 Comment(0)
C
1

Just try to remove "classpath:" from "change-log:" parameter. Also try to check your pom.xml ("changeLogFile" tag in configuration): there should not be a "${basedir}" before change log file path.

<changeLogFile>
  /src/main/resources/liquibase/changelog.xml
</changeLogFile>
Coelenteron answered 10/4, 2022 at 11:35 Comment(0)
M
0

I got the same issue. In my case, I found out we have a resource filtering maven plugin configured in pom.xml and the Liquibase SQL changelog file was not included.

The below code worked for me

<build>
    <resources>
        <resource>
            <filtering>true</filtering>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.sql</include>
            </includes>
        </resource>
    </resources>
</build>
Mu answered 25/4, 2023 at 6:32 Comment(0)
C
0

I faced this problem under IntelliJ with spring-boot 2.7.9 dependency during integration tests ran through the IDE.
But oddly, not when running these tests with Maven directly, on the command line.

Whatever, I changed the spring-boot dependency to spring-boot 2.7.14 and it solved my problem.

Caducity answered 18/8, 2023 at 7:6 Comment(0)
I
0

For me this is logged if the file doesn't exist.

Inland answered 18/7, 2024 at 20:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.