(Sharing my own workaround via Q/A)
I was getting the following error while trying to run liquibase as a standalone shell script, from the liquibase-3.6.2-bin.tar.gz
release:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/filter/Filter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
█
After some googling and inspecting the liquibase
shell script, I downloaded jars for these two projects:
- https://logback.qos.ch/download.html
- https://www.slf4j.org/download.html
Then I created a ./lib
directory relative to where the liquibase
lives and symlinked into it the following jars:
- logback-classic-1.2.3.jar
- logback-core-1.2.3.jar
- slf4j-api-1.7.25.jar
- slf4j-simple-1.7.25.jar
After these steps the command line liquibase worked.
I agree with these points made by one of the posters in this thread, sinc currently would be difficult to use liquibase as a standalone utility:
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.
There appears to be a bug report for the same issue in 3.6.0, but at least for me in 3.6.2 it has not been fixed.