mvn Liquibase:updateSql DatabaseException

Damien Cosset - Jul 2 '20 - - Dev Community

Hey there! I'm running into a problem inside my Spring boot application that is making me go nuts.

Here is the workflow:

  • Inside my Spring Boot application, I'm connecting to two databases.
  • Liquibase gets the differences between the two and generates a XML file as the changelog.
  • Then, I want to run mvn liquibase:updateSql to get the corresponding SQL from the changelog.

This workflow worked just fine until recently. Now, I get the following error:


[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.10.0:updateSQL (default-cli) on project api: 
[ERROR] Error setting up or running Liquibase:
[ERROR] java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.10.0:updateSQL (default-cli) on project api: 
Error setting up or running Liquibase:

Caused by: liquibase.exception.DatabaseException: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1
    at liquibase.changelog.OfflineChangeLogHistoryService.getRanChangeSets (OfflineChangeLogHistoryService.java:200)
    at liquibase.changelog.AbstractChangeLogHistoryService.upgradeChecksums (AbstractChangeLogHistoryService.java:66)
    at liquibase.Liquibase.checkLiquibaseTables (Liquibase.java:1174)
    at liquibase.Liquibase.update (Liquibase.java:192)
    at liquibase.Liquibase.update (Liquibase.java:268)
    at liquibase.Liquibase.update (Liquibase.java:250)
    at liquibase.Liquibase.update (Liquibase.java:396)
    at org.liquibase.maven.plugins.LiquibaseUpdateSQL.doUpdate (LiquibaseUpdateSQL.java:51)
    at org.liquibase.maven.plugins.AbstractLiquibaseUpdateMojo.performLiquibaseTask (AbstractLiquibaseUpdateMojo.java:30)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute (AbstractLiquibaseMojo.java:401)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Inside my pom.xml, I have the following:


<dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
        </dependency>

<!-- Some other stuff...-->
<plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>${liquibase.version}</version>
                    <configuration>
                        <!-- For mvn liquibase:updateSQL -->
                        <changeLogFile>src/main/resources/db/scripts/generated/liquibase/changes.xml</changeLogFile>
                        <migrationSqlOutputFile>src/main/resources/db/scripts/generated/liquibase/migration.sql</migrationSqlOutputFile>
                        <url>offline:postgresql</url>
                    </configuration>
                </plugin>

And this is an example of the XML that liquibase generated:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
    <changeSet author="damien (generated)" id="1593722682680-1">
        <addForeignKeyConstraint baseColumnNames="fk_user_id" baseTableCatalogName="new_version" baseTableName="user_activity" baseTableSchemaName="public" constraintName="fk1v0u4vq1s7h8hcdb12mt1llb3" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableCatalogName="new_version" referencedTableName="api_user" referencedTableSchemaName="public" validate="true"/>
    </changeSet>
    <changeSet author="damien (generated)" id="1593722682680-2">
        <addColumn catalogName="new_version" schemaName="public" tableName="user_activity">
            <column defaultValueComputed="('now'::text)::date" name="created_on" type="timestamp">
                <constraints nullable="false"/>
            </column>
        </addColumn>
    </changeSet>
    <changeSet author="damien (generated)" id="1593722682680-3">
        <addColumn catalogName="new_version" schemaName="public" tableName="api_user">
            <column name="background_image" type="bytea"/>
        </addColumn>
    </changeSet>
    <changeSet author="damien (generated)" id="1593722682680-4">
        <addColumn catalogName="new_version" schemaName="public" tableName="api_user">
            <column defaultValue="NULL::character varying" name="bio" type="varchar(300 BYTE)"/>
        </addColumn>
    </changeSet>
</databaseChangeLog>

I'm using the version 3.6.3 of Liquibase.

I have tried different liquibase versions but I always get the same error.

Do you have any idea what this DatabaseException refers to?

Thank you!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .