Issue
I use Spring 2.3.3 and Liquibase 4.0.0. It works fine when run gradlew bootRun, but when I run compiled jar I get plenty of messages like:
2020-09-11 17:40:33.267 WARN 1 --- [ main] liquibase.integration : Cannot create filesystem for url jar:file:/app.jar!/BOOT-INF/lib/spring-aspects-5.2.8.RELEASE.jar!/: null
java.nio.file.FileSystemNotFoundException: null
...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfigurati
on.class]: Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: Error parsing classpath:/db/changelog/db.changelog-master.yaml
Liqubase gradle config and runtime libraries:
configurations {
liquibaseRuntime.extendsFrom runtime
compileOnly {
extendsFrom annotationProcessor
}
Properties liquibaseProps = new Properties()
liquibaseProps.load(new FileInputStream("src/main/resources/liquibase.properties"))
Properties applicationProps = new Properties()
applicationProps.load(new FileInputStream("src/main/resources/application.properties"))
liquibase {
activities {
main {
referenceUrl 'hibernate:spring:' + liquibaseProps.getProperty('liquibase.domain.package') + '?dialect=' + applicationProps.getProperty('spring.jpa.database-platform') + '&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
driver applicationProps.getProperty('spring.datasource.driver-class-name')
changeLogFile liquibaseProps.getProperty('liquibase.changelog.path') + migrationName() + '.yaml'
url applicationProps.getProperty('spring.datasource.url')
username applicationProps.getProperty('spring.datasource.username')
password applicationProps.getProperty('spring.datasource.password')
}
}
}
}
Runtime:
liquibaseRuntime 'org.liquibase:liquibase-core:4.0.0'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.1.2'
liquibaseRuntime 'org.postgresql:postgresql'
liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:4.0.0'
liquibaseRuntime sourceSets.main.output
liquibaseRuntime "ch.qos.logback:logback-core"
liquibaseRuntime "ch.qos.logback:logback-classic"
liquibaseRuntime 'org.yaml:snakeyaml'
liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-security'
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-web'
liquibase.properties:
liquibase.changelog.path="classpath:src/main/resources/db/changelog/changes/"
liquibase.domain.package=ru.example.entities
Application configuration application.properties
spring.application.name = "Example"
application.description = "Example"
application.version = 1.0
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQL10Dialect
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.hibernate.naming.implicit-strategy = org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql:localhost:5432/test
spring.datasource.username=postgres
spring.datasource.password=qwerty
How can I fix it?
Update:
Updated resources/db/changelog/db.changelog-master.yaml:
databaseChangeLog:
- includeAll:
path: classpath:db/changelog/changes/
Updated liquibase config in gradle:
liquibase {
activities {
main {
classpath "$projectDir/src/main/resources/db/changelog"
...
Added to application.properties: spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.yaml
Now I still get a warnings about not found jar dependencies:
liquibase.integration : Cannot create filesystem for url jar:file:/app.jar!/BOOT-INF/lib/spring-aspects-5.2.8.RELEASE.jar!/: null
java.nio.file.FileSystemNotFoundException: null
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:172) ~[jdk.zipfs:na]
And still not found embedded changeset:
Could not find directory or directory was empty for includeAll 'db/changelog/changes/'
Problem with includeAll fixes if replace it with explicit declaration:
databaseChangeLog:
- include:
file: changes/20200829022849_default.yaml
relativeToChangelogFile: true
Update 2 Here is a link on repository https://github.com/dekar91/liquibase_ex I build and start application like so:
./gradleew bootJar
java -jar example-0.0.1-SNAPSHOT.jar
Solution
This is a commited liquibase 4.0.0 issue https://github.com/liquibase/liquibase/issues/1276 Liuquibase 3.10.2 works correctly.
Answered By - Dekar
Answer Checked By - Marilyn (JavaFixing Volunteer)