Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant run liquibase with command line

I want to use liquibase but when I want to let it run with command line this happens:

PS C:\Users\Ferid\Downloads\liquibase-3.6.0-bin> .\liquibase
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(Unknown Source)
    at java.lang.Class.privateGetMethodRecursive(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
 Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more

I have tried liquibase-3.6.1 and now liquibase-3.6.0

like image 675
Mad Scientist Avatar asked May 23 '18 11:05

Mad Scientist


People also ask

How do I run Liquibase manually?

In this article, we'll cover what you can do once you've created a database changelog file and you're ready to go: Embed Liquibase into your product. Embed Liquibase into your build tools. Run Liquibase to generate SQL for review.


2 Answers

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:

  1. Get the library yourself [here].
  2. Wait for the patched version (Maybe submit a fix yourself).
  3. Revert to an older version (3.5.5 Should work)

See here for the bug report: https://liquibase.jira.com/browse/CORE-3201

like image 52
sorifiend Avatar answered Oct 19 '22 03:10

sorifiend


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

like image 34
Alan Hernandez Avatar answered Oct 19 '22 03:10

Alan Hernandez