Error while running from command line java -jar liquibase.jar

When I run below command in liquibase 3.9.0 under extracted root folder I am getting below error. Please advice

liquibaseextracteddirectory>>java -jar liquibase.jar
Error: Unable to initialize main class liquibase.integration.commandline.Main
Caused by: java.lang.NoClassDefFoundError: ch/qos/logback/core/Context

Hi
Can you run liquibase --version command and see if gives you output as expected?

Please find the output of the version command

Starting Liquibase at Wed, 28 Oct 2020 11:30:45 IST (version 3.9.0 #11 built at Thu May 14 04:03:56 UTC 2020)
Liquibase Version: 3.9.0
Liquibase Community 3.9.0 by Datical

Thats good. Can you run a command like “history” or “updateSQL”. I have not seen this error and I will wait for other mods to respond as well.

Via liquibase.bat run commands update, updatesql works fine. But when I run via java -jar only it fails

Could we see the complete error output?

What does that mean ^

Where did the liquibase.jar come from? if you are in the liquibase install directory, why are you running it via ‘java -jar’ instead of just calling ./liquibase [command]?

1 Like

Hi

Thanks for your reply.

We meant extracted folder as, unzipped folder location of downloaded liquibase-3.9.0.zip. ./liquibase command works fine. We are using java -jar as we want to take db files from particular war file, following below command as per liquibase documentation

java -jar liquibase.jar
–driver=oracle.jdbc.OracleDriver
–classpath=website.war
–changeLogFile=xxxxxl
–url=jdbc:oracle:xxx
–username=xxx
–password=xxx
update

Where did you get this command from? I am looking at this documentation:

And classpath is supposed to point to your oracle jdbc jar, not a war file. Liquibase looks for db scripts by looking at the value of changeLogFile, and sometimes, the changeLogFile can include a directory.

So, please:

  • change your classpath to the full path and filename of your oracle jdbc driver jar.
  • point liquibase to a changelog via commandline or liquibase.properties file and set the changeLogFile property.

After that, what error do you see?

Thanks,

Ronak

Thanks for the reply.

It is in the same link provided, under section Run update pulling changelogs from a .WAR file. Trying that option.

Even if I give only java -jar liquibase.jar it fails with below output. I tried different options like passing -cp with lib folder of liquibase, -classpath of lib folder, even then it fails.

Error: Unable to initialize main class liquibase.integration.commandline.Main
Caused by: java.lang.NoClassDefFoundError: ch/qos/logback/core/Context

I see, and what value do you have for changelogfile? I noticed it is redacted but it should follow reverse domain notation relative to War root like this:

--changeLogFile=com/example/db.changelog.xml

Thanks for the reply.

Yes I have given reference path in the war only. It is not going to the stage of taking the change log it fails before that. If I give plain execution of just java -jar liquibase.jar it fails, it seems to be not recognizing the lib folder where liquibase jars are available. I tried giving CP, classpath to the lib folder it still did not recognize, hence need to understand liquibase.jar how it takes other jars in lib folder for liquibase eg.logback-core-1.2.3.jar

liquibaseextracteddirectory>>java -jar liquibase.jar
Error: Unable to initialize main class liquibase.integration.commandline.Main
Caused by: java.lang.NoClassDefFoundError: ch/qos/logback/core/Context