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

Sorry for the delay in response.

May I see it denoted in your liquibase.properties file? I am not sure what exactly this statement means.

Thanks Ronan for the follow-up, Yes have provided like with reference to the war path. --changeLogFile=WEB-INF/classes/db/migration/dbchangelog.xml

If we give plain execution of just java -jar liquibase.jar it fails,ch/quos/logback is in the logback*.jar that comes as part of liquibase/lib folder, it does not recognize it. I tried giving CP, classpath to the lib folder it did not work.

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 @selvakumarm,

I am still not able to understand what you are trying to do. Maybe you can sign up for a Liquibase Pro Trial and that will let you talk to a support person to see what you are doing. The description so far leaves me still wondering where you are running java from and why liquibase is looking in ch/quos/…

Support I am sure can get you sorted out quickly,

Ronak

Good information thanks for sharing
Fieldengineer

I faced the problem - when I tried to run “java -jar liquibase-core.jar” I saw following error:

java -jar liquibase-core-4.23.0.jar
Exception in thread “main” java.lang.ClassNotFoundException: liquibase.integration.commandline.LiquibaseCommandLine
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:105)

Problem was solved when I added CORRECT variable for LIQUIBASE_HOME:
It shouldn’t be folder with “liquibase-core.jar”
but it should be folder that contains following folders structure:
%LIQUIBASE_HOME%\internal\lib\liquibase-core.jar

After I changed this variable, everything started working fine.