2

I want to run Liquibase standalone (i.e. w/o "installation") on the command line. However, whatever I tried I'm getting java.lang.ClassNotFoundException: ch.qos.logback.core.Context or some other logback class.

I checked the Liquibase pom.xml to find out exactly which dependencies it needs and provided them accordingly.

1. attempt

java -jar liquibase-core-3.8.6.jar \
     -cp jaxb-api-2.3.0.jar:snakeyaml-1.24.jar:slf4j-api-1.7.28.jarlogback-core-1.2.3.jar::logback-classic-1.2.3.jar \
     --classpath=backend/target/mywar.war \
     --changeLogFile=db/changelog/db.changelog-master.xml

2. and further attempts

I understand that -cp is the regular classpath parameter for the java command and --classpath is a program argument for Liquibase as per the documentation. Yet, I still tried various combinations of parameters of the 1st attempt but to no avail.

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
  • my understanding is this, you first install liquibase so that it can be added in classpath, after that run command liquibase [options] [command] – Umar Tahir Feb 26 '20 at 20:10
  • maybe a typo in the `-cp` parameter? `:` missing between `slf4j-api-1.7.28.jar` and `logback-core-1.2.3.jar` – Daniele Feb 26 '20 at 20:12
  • Looks similar to https://stackoverflow.com/questions/50487054/cant-run-liquibase-with-command-line. – Dmitriy Popov Feb 26 '20 at 20:13
  • liquibase [options] [command] corresponds to liquibase --classpath=mysql-connector-java-5.1.21-bin.jar --url="jdbc:mysql://" --changeLogFile=db.changelog-1.0.xml --username= --password= – Umar Tahir Feb 26 '20 at 20:14
  • above mentioned options are necessary to specify. – Umar Tahir Feb 26 '20 at 20:15

1 Answers1

2

Arghh, silly me. With all the IDE magic these days you forget how to start a Java program on the CLI.

You can't combine -jar and -cp i.e. you can't put additional JARs on the classpath with -jar.

So, to fix this you need to java -cp ... liquibase.integration.commandline.Main --classpath=....

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198