Unable to launch liquibase using command line

When I run the following command from the prompt I get the error below for version 3.6.1 and 3.6.0. whereas when I run the same command for 3.5.3 , it gives the response that command not passed.

However when I run the liquibase shell script it works fine. I even tried adding the jars to the classpath it still gives the same error. Below are the errors and the steps that I had followed.

Any advice ?

  1. devbox@:~/liquibase/3.6.1> java -jar liquibase.jar Exception in thread "main" java.lang.NoClassDefFoundError: ch.qos.logback.core.f                                                 ilter.Filter         at java.lang.J9VMInternals.verifyImpl(Native Method)         at java.lang.J9VMInternals.verify(J9VMInternals.java:94)         at java.lang.J9VMInternals.prepare(J9VMInternals.java:514)         at java.lang.Class.getMethod(Class.java:1116)         at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:507)         at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:499) Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter         at java.net.URLClassLoader.findClass(URLClassLoader.java:600)         at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:777)         at java.lang.ClassLoader.loadClass(ClassLoader.java:750)         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)         at java.lang.ClassLoader.loadClass(ClassLoader.java:731)
  2. devbox@:~/liquibase/3.6.1> liquibase .:/export/home/devbox/liquibase/3.6.1/liquibase.jar:/export/home/devbox/liquibase/3.6.1/lib/:/export/home/devbox/liquibase/3.6.1/lib/logback-c                                                                                               lassic-1.2.3.jar:/export/home/devbox/liquibase/3.6.1/lib/logback-core-1.2.3.jar:/export/home/devbox/liquibase/3.6.1/lib/ojdbc6.jar:/export/hom                                                                                               e/devbox/liquibase/3.6.1/lib/slf4j-api-1.7.25.jar:/export/home/devbox/liquibase/3.6.1/lib/snakeyaml-1.18.jar
  3. Starting Liquibase at Wed, 23 May 2018 04:30:07 BST (version 3.6.1 built at 2018-04-11 08:41:04) Errors:   No command was passed.
  4. devbox@:~/liquibase/3.6.1> export CP=".:/export/home/devbox/liquibase/3.6.1/liquibase.jar:/export/home/devbox/liquibase/3.6.1/li                                                                                               b/:/export/home/devbox/liquibase/3.6.1/lib/logback-classic-1.2.3.jar:/export/home/devbox/liquibase/3.6.1/lib/logback-core-1.2.3.jar:/export/ho                                                                                               me/devbox/liquibase/3.6.1/lib/ojdbc6.jar:/export/home/devbox/liquibase/3.6.1/lib/slf4j-api-1.7.25.jar:/export/home/devbox/liquibase/3.6.1/lib/                                                                                               snakeyaml-1.18.jar" devbox@:~/liquibase/3.6.1> echo $CP .:/export/home/devbox/liquibase/3.6.1/liquibase.jar:/export/home/devbox/liquibase/3.6.1/lib/:/export/home/devbox/liquibase/3.6.1/lib/logback-c                                                                                               lassic-1.2.3.jar:/export/home/devbox/liquibase/3.6.1/lib/logback-core-1.2.3.jar:/export/home/devbox/liquibase/3.6.1/lib/ojdbc6.jar:/export/hom                                                                                               e/devbox/liquibase/3.6.1/lib/slf4j-api-1.7.25.jar:/export/home/devbox/liquibase/3.6.1/lib/snakeyaml-1.18.jar
  5. devbox@:~/liquibase/3.6.1> java -cp $CP -jar liquibase.jar Exception in thread "main" java.lang.NoClassDefFoundError: ch.qos.logback.core.filter.Filter         at java.lang.J9VMInternals.verifyImpl(Native Method)         at java.lang.J9VMInternals.verify(J9VMInternals.java:94)         at java.lang.J9VMInternals.prepare(J9VMInternals.java:514)         at java.lang.Class.getMethod(Class.java:1116)         at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:507)         at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:499) Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter         at java.net.URLClassLoader.findClass(URLClassLoader.java:600)         at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:777)         at java.lang.ClassLoader.loadClass(ClassLoader.java:750)         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)         at java.lang.ClassLoader.loadClass(ClassLoader.java:731)         ... 6 more

Is there a reason you don’t just run the shell script? If you want to replicate what the shell script does, it is there to examine. If you want to see what it is doing, you can alter the shell script to show the command it is actually running at the end. Here is an example:

The liquibase script as shipped ends with these lines:


$_CMD


Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Here is what the output looks like on my machine:

steve@SteveDonieCentOSVBox ~/work/Liquibase-CLI-testing/bin[master]$ ./liquibase

java -cp “.:/home/steve/work/Liquibase-CLI-testing/bin/liquibase.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/:/home/steve/work/Liquibase-CLI-testing/bin/lib/appdba-1.0.315.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/com.datical.db.drivers.db2_1.0.0.SNAPSHOT.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/com.datical.db.drivers.mssql_1.0.9.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/DaticalJDBC-0.0.57.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/db2jcc.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/db2jcc_license_cisuz.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/h2.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/keymgr.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/liquibase-slf4j-2.0.0.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/logback-classic-1.2.3.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/logback-core-1.2.3.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/mysql-connector.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/ojdbc6-11.2.0.3.0.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/postgresql-9.2-1003-jdbc4.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/slf4j-api-1.7.12.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/snakeyaml-1.17.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/storedlogic-1.0.195-SNAPSHOT.jar:/home/steve/work/Liquibase-CLI-testing/bin/lib/xercesImpl-2.11.0.SP5.jar” liquibase.integration.commandline.Main

Errors:

  Command not passed

Usage: java -jar liquibase.jar [options] [command]

Standard Commands:

 update                         Updates database to current version

 updateSQL                      Writes SQL to update database to current

                                version to STDOUT

(rest of output clipped)
Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Looking more closely at your classpath vs. mine, it appears that the issue is you are missing the logback-classic jar.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

I just tried to upgrade as well from a 3.5.X build to 3.6.X (3.6.2 specifically although this seems to be general to the minor version bump):  I *do use the script and it pulls in the %LIQUIBASE_HOME%/lib folder’s jars which from 3.5 -> 3.6 added logback. That is what it is but honestly Liquibase should be an uber jar. Pulling in a lib folder is not the way to do that anymore and causes problems such as when someone tries to run from the jar instead of some packaged script.

All that being said: There is a still a bug. Using the script I got an additional NoClassDefDFound error because it was missing the SLF4J api jars… We use that in other projects so I just grabbed my latest copy of that jar from my MVN repo (slf4j-api-1.7.25.jar) dropped it in the lib folder and that got me past the issue so…

  1. This release is missing a required library to be self-sufficient.

  2. Further more: The packaging of the Liquibase jar should switch from utilizing a lib/ folder to being an Uber jar with all required libs included.