ClassNotFoundException running Liquibase standalone on command line

Viewed 1688

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.

1 Answers

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=....

Related