Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected error running Liquibase: Unknown reason Throwing NPE

Been using Liquibase a long time, and love it. However, on the project I'm currently working on, I'm encountering an issue I don't seem to be able to find the cause.

I can run every changelog/feature/*.xml file from the command line (using update) and everything succeeds.

I can run every db.changelog-*.xml file (except master) from the command line (using update) and everything succeeds.

But when I try and run the db.changelog-master file, I get:

Starting Liquibase at Tue, 14 Apr 2020 11:49:47 CDT (version 3.8.0 built at 2019-08-15T20:38:06Z)
Liquibase Community 3.8.0 by Datical
Unexpected error running Liquibase: Unknown reason
liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException
    at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25) ~[liquibase.jar:na]
    at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217) ~[liquibase.jar:na]
    at liquibase.Liquibase.update(Liquibase.java:190) ~[liquibase.jar:na]
    at liquibase.Liquibase.update(Liquibase.java:179) ~[liquibase.jar:na]
    at liquibase.integration.commandline.Main.doMigration(Main.java:1223) [liquibase.jar:na]
    at liquibase.integration.commandline.Main.run(Main.java:209) [liquibase.jar:na]
    at liquibase.integration.commandline.Main.main(Main.java:132) [liquibase.jar:na]
Caused by: liquibase.exception.SetupException: null
    at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:531) ~[liquibase.jar:na]
    at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:398) ~[liquibase.jar:na]
    at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:308) ~[liquibase.jar:na]
    at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23) ~[liquibase.jar:na]
    ... 6 common frames omitted
Caused by: java.lang.NullPointerException: null
    at java.util.AbstractCollection.addAll(AbstractCollection.java:343) ~[na:1.8.0_242]
    at liquibase.integration.commandline.CommandLineResourceAccessor.list(CommandLineResourceAccessor.java:44) ~[liquibase.jar:na]
    at liquibase.resource.CompositeResourceAccessor.list(CompositeResourceAccessor.java:40) ~[liquibase.jar:na]
    at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:506) ~[liquibase.jar:na]
    ... 9 common frames omitted


For more information, please use the --logLevel flag

I did find an old view and trigger that were created during research for the project for a different schema, which were never run in this one (neither was in this DATABASECHANGELOG). They've been deleted, but the problem still exists.

Running:

  • macOS Catalina 10.15.3
  • openjdk version "1.8.0_242"
  • OpenJDK Runtime Environment (Zulu 8.44.0.11-CA-macosx) (build 1.8.0_242-b20)
  • OpenJDK 64-Bit Server VM (Zulu 8.44.0.11-CA-macosx) (build 25.242-b20, mixed mode)
  • Oracle Database 11g Enterprise Edition Release 11.2.0.2.0
  • 64bit Production PL/SQL Release 11.2.0.2.0 Production
  • CORE 11.2.0.2.0 Production
  • TNS for Linux: Version 11.2.0.2.0 Production
  • NLSRTL Version 11.2.0.2.0 Production
  • Liquibase 3.8.0

Tried everything I can think of. Anyone have any thoughts?


**UPDATE APR-29-2020**
I have a little more information - I've discovered WHAT is happening, and the plan to fix this isn't working.

The what: Apparently Liqiubase changed the includeAll path somewhere between version 3.4.2 and 3.5.5: See 'Upgrade from 3.4.2 to 3.5.5 or higher'

I'd copied our liquibase setup from a legacy system running 3.4.2. In the db.changelog-master.xml file, it has <includeAll path="/features"/> (leading slash). However, on the new project, I upgraded to 3.8.0. And the includeAll is what's throwing the exception.

The new value is <includeAll path="features/"/> (trailing slash). The format for the FILENAME column in DATABASECHANGELOG is the same, i.e. features/20191024-LD-1.xml

In the documentation, there's a command line maintenance command that looks perfectly designed for this fix: cleanCheckSums. Per the website:

Removes current checksums from database. On next update changesets that have already been deployed will have their checksums recomputed, and changesets that have not been deployed will be deployed.

Challenge is that yes, cleanCheckSums nulls the MD5SUM column, the EXECTYPE column is EXECUTED, and each row has a populated DEPLOYMENT_ID, but the next update command tries to re-run all of the changesets.

Here's the plan we created for the fix:

Steps

  1. Change the includeAll parameter path in db.changelog-master.xml:
    <includeAll path="features/"/>

  2. Run liquidate clearCheckSums:
    $LIQUIBASE_HOME/liquibase \ --driver=oracle.jdbc.OracleDriver \ --classpath=/data/apps/liquibase-3.8.0/ojdbc7.jar \ --url={pathToDatabase} \ --username={dbUserName} \ --password={dbUserPass} \ clearCheckSums

  3. SQL to fix the database column filename to the expected format
    Appears to be exactly the same format:
    old: features/20191024-LD-1.xml
    new test: features/20200429-deleteme.xml

  4. Run master update:
    $LIQUIBASE_HOME/liquibase \ --driver=oracle.jdbc.OracleDriver \ --classpath=/data/apps/liquibase-3.8.0/ojdbc7.jar \ --url={pathToDatabase} \ --changeLogFile=db.changelog-master.xml \ --username={dbUserName} \ --password={dbUserPass} \ update

Anyone know what I'm missing?

like image 243
LinuxLars Avatar asked Jan 01 '26 02:01

LinuxLars


1 Answers

Please try the following command:

liquibase changelogSync

This command will create corresponding rows to the db.changelog-master.xml changeSets in the DATABASECHANGELOG tracking table and consider those changeSets as deployed.

like image 174
TsviZan Avatar answered Jan 06 '26 11:01

TsviZan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!