Cant run liquibase with command line
I stumbled upon the same issue in version 3.6.2
. The problem is that Liquibase can't find the required classes (ch.qos.logback.core.filter.Filter
being just one of them, but there are others). There is no universal recipe, but the high-level idea is to found JARs the required classes live in and feed them to the -cp
command-line parameter. Looks a bit ugly but this is what finally worked:
#!/bin/bash
M2_REPO=/home/raiks/.m2/repository
LIQUIBASE_CMDLINE='liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update'
# Feed all the required JARs to -cp
JAVA_CMD="java -cp $M2_REPO/org/liquibase/liquibase-core/3.6.2/liquibase-core-3.6.2.jar:$M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar:$M2_REPO/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:$M2_REPO/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar $LIQUIBASE_CMDLINE"
echo $JAVA_CMD
eval $JAVA_CMD
Please note that I use :
on Linux while ;
will be required on Windows. Adjust the command according to your specific JAR location.
Alternatively, you can put dependencies to a directory and specify it with a wildcard after -cp
:
$ java -cp "/home/raiks/liquibase-deps/*" liquibase.integration.commandline.Main --changeLogFile=~/changelog-master.xml update
One of the required libraries is missing from the library folder.
See the bug report link below where another user had the same issue.
It appears 3.6.1 is still missing slf4j-api-1.7.25 in the lib folder and I still receive an error invoking liquibase via cli.
You have three options:
- Get the library yourself [here].
- Wait for the patched version (Maybe submit a fix yourself).
- Revert to an older version (3.5.5 Should work)
See here for the bug report: https://liquibase.jira.com/browse/CORE-3201
You must add this libraries to your classpath:
- logback-core
- logback-clasic
In my case I am using Spring Boot liquibase integration, so, here is my build.gradle
liquibase configutarion
buildscript {
dependencies {
classpath 'org.postgresql:postgresql:9.4.1211.jre7'
classpath 'org.liquibase:liquibase-core:3.6.3'
classpath "org.liquibase:liquibase-gradle-plugin:2.0.1"
}
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
id "org.liquibase.gradle" version "2.0.1"
}
dependencies {
liquibaseRuntime 'org.postgresql:postgresql:9.4.1211.jre7'
liquibaseRuntime 'org.liquibase:liquibase-core:3.6.3'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1'
liquibaseRuntime 'ch.qos.logback:logback-core:1.2.3'
liquibaseRuntime 'ch.qos.logback:logback-classic:1.2.3'
}
def changeLog = "$projectDir/src/main/db/changelog.xml"
liquibase {
activities {
main {
changeLogFile changeLog
url 'jdbc:postgresql://localhost:5431/postgres'
username 'postgres'
password 'postgres'
}
}
}
It's an extract from liquibase-gradle-plugin