Starting version 4.4.0 we're not able to run liquibase

Hi,

I’m trying to upgrade our liquibase core from 4.3.3 to 4.9.1, quite a big jump, unfortunately when the container tried to run liquibase it encountered an exception with minimal info.

By the way, we package it in a docker image running Debian GNU/Linux 11 and
openjdk version “1.8.0_322”
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

So I tried to investigate which version where the problem started…
I tried 4.3.5 next to 4.3.3 but no issue///
but when I used 4.4.0, I encountered this exception “Unexpected error running Liquibase: java.lang.NullPointerException” What’s the possible root cause of this error?

this is the command we run as part of the shell script:

java -Xms${MEMORY_REQUEST} -Xmx${MEMORY_REQUEST} -cp “liquibase.jar:./lib/*” liquibase.integration.commandline.LiquibaseCommandLine
–changeLogFile=./changelog/${COMPONENT_NAME}/db.changelog-master.xml
–url=“jdbc:sqlserver://${DB_HOST}:${DB_PORT:-1433};databaseName=${DATABASE_NAME}${DB_SUFFIX};encrypt=${DB_TLS_CONNECT}”
–username=${DB_USER}
–password=${DB_PASS}
–labels=${LIQUIBASE_LABELS}
–logLevel=${LOG_LEVEL}
update

here’s the changelog:

<?xml version="1.0" encoding="UTF-8"?>

<changeSet author="BankFast" id="5.15.0.15" failOnError="true">
  <sqlFile dbms="mssql" path="./changelog/BankFast/createAllTables_sqlserver.sql" />

Weird is I was able to run liquibase on my local laptop but not in docker container.

here are the libraries or dependencies used for liquibase core 4.4.0:

  • jaxb-api-2.3.0.jar
    -jaxb-core-2.3.0.jar
    -jaxb-impl-2.3.0.jar
  • picocli-4.6.1.jar
    -snakeyaml-1.27.jar

Any suggestion on how I can fix this?

Thanks,
Eugene

So I updated 3.8.6 to 4.3.4 and then up to 4.9.1 and had no such issue. Are you trying to run this on an Apple M1 by any chance? Also, I’ll go look at our code and see how we have it set up. Can you show us your Dockerfile?

Here is the command that we’re running:

docker exec <container_name> liquibase --url=“jdbc:mysql://db:3306/${DB}” update

I’m just shocked it’s not working. Let me see if I can duplicate.

Edit: I was not able to duplicate it. 4.4.0 ran fine as did 4.9.1. Idk.

Thanks @erinlkolp :slight_smile:

I’m deploying it on kubernetes container.
actually when I tried it on my ubuntu terminal environment (WSL) installed on my windows, I’m able to run liquibase but when I run it in the container that’s where that exception is happening.

here’s the content of our dockerfile

> FROM alpine:3.15.4 as builder
>
> RUN mkdir -p /base
> RUN mkdir -p /base/lib
> COPY lib/ /base/lib #I have local lib (use for testing only) available already in my local that's why i commented out lib download below
> WORKDIR /base
>
> # From version 4.6.2 maven no longer publish zip copy of liquibase
> RUN wget (..URL)/liquibase-core/4.9.1/liquibase-core-4.9.1.jar -O ./liquibase.jar
> RUN wget (..URL)/mssql-jdbc-10.2.0.jre8.jar -O ./lib/mssql-jdbc-10.2.0.jre8.jar
> # Download Luiqbase core 4.9.1 dependencies
> #RUN wget https://repo1.maven.org/maven2/org/yaml/snakeyaml/1.27/snakeyaml-1.27.jar -O ./lib/snakeyaml-1.27.jar
> #RUN wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar -O ./lib/jaxb-api-2.3.0.jar
> #RUN wget https://repo1.maven.org/maven2/info/picocli/picocli/4.6.1/picocli-4.6.1.jar -O ./lib/picocli-4.6.1.jar
>
> FROM openjdk:8u322-jre-slim
>
> WORKDIR /liquibase
> COPY --from=builder /base/ /liquibase
>
> ENV DB_HOST=testdb \
> DB_PORT="1433" \
> DB_TLS_CONNECT="false" \
> DB_USER=(####) \
> DB_PASS=(####) \
> DB_SUFFIX="" \
> DATABASE_NAME="" \
> DATABASE_UPDATE="AUTO" \
> LOG_LEVEL=INFO \
> COMPONENT_NAME=""
>
> ENV MEMORY_LIMIT "1G"
> ENV MEMORY_REQUEST "512M"
>
> COPY liquibase.properties /liquibase/liquibase.properties
> COPY init.sh /usr/local/bin/

and what initialize liquibase is this init.sh being executed upon deploying to kubernetes


cd /liquibase
mkdir -p changelog
cp -r /config/sql/* ./changelog

echo "TLS connection to database is ${DB_TLS_CONNECT}"
echo ---- Run the component init file to update the component database script -----

if [ -e changelog/${COMPONENT_NAME}/init.sh ];
then
  echo --- Run the container init.sh file---
  source ./changelog/${COMPONENT_NAME}/init.sh
fi

if [ -z "$DATABASE_UPDATE" ] || [ "AUTO" = `(echo "$DATABASE_UPDATE" | tr '[:lower:]' '[:upper:]')` ] ;
then
  echo ----- Run ${DATABASE_NAME}${DB_SUFFIX} Changelog -----  
  java -Xms${MEMORY_REQUEST} -Xmx${MEMORY_REQUEST} -cp "liquibase.jar:./lib/*" liquibase.integration.commandline.LiquibaseCommandLine \
    --changeLogFile=./changelog/${COMPONENT_NAME}/db.changelog-master.xml \
    --url="jdbc:sqlserver://${DB_HOST}:${DB_PORT:-1433};databaseName=${DATABASE_NAME}${DB_SUFFIX};encrypt=${DB_TLS_CONNECT}" \
    --username=${DB_USER} \
    --password=${DB_PASS} \
    --labels=${LIQUIBASE_LABELS} \
    --logLevel=${LOG_LEVEL} \
    update
fi

Thank you so much!

Unfortunately I have no experience with Kubernetes. Your Dockerfile looks fine, and is pretty close (in intent) to the official liquibase-docker image’s file: here. Have you thought about using the official docker images on docker hub as your base? I’m curious if they’d produce the same np exception… Hmm…

I really like your implementation and commitment to slim docker images!

1 Like

Hi @erinlkolp ,

Apologies for very late reply.
I was able to run the liquibase container but instead of this base image openjdk:8u322-jre-slim on Debian 11 OS:

java -version

openjdk version “1.8.0_322”
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

cat /etc/os-release

PRETTY_NAME=“Debian GNU/Linux 11 (bullseye)”
NAME=“Debian GNU/Linux”
VERSION_ID=“11”
VERSION=“11 (bullseye)”
VERSION_CODENAME=bullseye
ID=debian

I used Ubuntu 20.04 as my based image and installed java8

FROM ubuntu:20.04

RUN apt-get update &&
DEBIAN_FRONTEND=noninteractive
apt-get -y install openjdk-8-jre-headless &&
apt-get clean &&
rm -rf /var/lib/apt/lists/*

I’m not really why it failed in Debian 11 OS, any idea?

Thanks,
Eugene

I tried to investigate further and found that when application run via BASH it does not load other java class

java -Xms${MEMORY_REQUEST} -Xmx${MEMORY_REQUEST} -cp “liquibase.jar:./lib/*” liquibase.integration.commandline.LiquibaseCommandLine
–changeLogFile=./changelog/${COMPONENT_NAME}/db.changelog-master.xml
–url=“jdbc:sqlserver://${DB_HOST}:${DB_PORT:-1433};databaseName=${DATABASE_NAME}${DB_SUFFIX};encrypt=${DB_TLS_CONNECT}”
–username=${DB_USER}
–password=${DB_PASS}
–labels=${LIQUIBASE_LABELS}
–logLevel=${LOG_LEVEL}
update

I tried to add -verbose option in java command as in
java -Xms${MEMORY_REQUEST} -Xmx${MEMORY_REQUEST} -cp “./liquibase.jar:./lib/*” -verbose:class liquibase.integration.commandline.LiquibaseCommandLine \

and it shows this error
Unexpected error running Liquibase: java.lang.NullPointerException

and it occurred while loading java class

[Opened /usr/local/openjdk-8/lib/rt.jar]
[[Loaded liquibase.pro.packaged.mE from file:/liquibase.jar]
[Loaded liquibase.pro.packaged.mF from file:/liquibase.jar]
[Loaded liquibase.util.LiquibaseUtil from file:/liquibase.jar]
[Loaded java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$1 from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntry from /usr/local/openjdk-8/lib/rt.jar]

Unexpected error running Liquibase: java.lang.NullPointerException

For more information, please use the --log-level flag
[Loaded java.util.IdentityHashMap$KeySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.IdentityHashMap$IdentityHashMapIterator from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.IdentityHashMap$KeyIterator from /usr/local/openjdk-8/lib/rt.jar]
[Loaded jdk.internal.misc.TerminatingThreadLocal$1 from /usr/local/openjdk-8/lib/rt.jar]
+ exit 1

looks like not able to load the following class:

[Loaded java.util.TreeMap$EntrySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.TreeMap$EntryIterator from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.configuration.ProvidedValue from file://liquibase.jar]
[Loaded java.util.Collections$SingletonList from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.configuration.ConfigurationDefinition$DefaultValueProvider from file:[Loaded java.util.TreeMap$EntrySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.util.TreeMap$EntryIterator from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.configuration.ProvidedValue from file://liquibase.jar]
[Loaded java.util.Collections$SingletonList from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.configuration.ConfigurationDefinition$DefaultValueProvider from file://liquibase.jar]
[Loaded liquibase.configuration.core.DefaultsFileValueProvider from file://liquibase.jar]
[Loaded java.lang.invoke.LambdaForm$DMH/802243390 from java.lang.invoke.LambdaForm]
[Loaded liquibase.configuration.core.DefaultsFileValueProvider$$Lambda$55/702061917 from liquibase.configuration.core.DefaultsFileValueProvider]
[Loaded liquibase.util.SystemUtil from file://liquibase.jar]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$56/1771667101 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded liquibase.configuration.ConfigurationDefinition$ConvertedValueProvider from file://liquibase.jar]
[Loaded liquibase.resource.CompositeResourceAccessor from file://liquibase.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor from file://liquibase.jar]
[Loaded java.nio.file.InvalidPathException from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor$CloseChildWillCloseParentStream from file://liquibase.jar]
[Loaded java.util.zip.GZIPInputStream from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor$1 from file://liquibase.jar]
[Loaded java.nio.file.FileSystems from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.nio.file.FileSystems$DefaultFileSystemHolder from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.nio.file.FileSystems$DefaultFileSystemHolder$1 from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.util.CollectionUtil from file://liquibase.jar]
[Loaded liquibase.integration.commandline.CommandLineResourceAccessor from file://liquibase.jar]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$57/510147134 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$58/341138954 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded sun.security.provider.SecureRandom from /usr/local/openjdk-8/lib/rt.jar]
[Loaded sun.security.provider.SHA from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.pro.packaged.mz$3 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nc$2 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nb$2 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nb$2$1 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nc$2$1 from file://liquibase.jar]
[Loaded javax.crypto.CipherInputStream from /usr/local/openjdk-8/lib/jce.jar]
[Loaded java.lang.ProcessEnvironment$StringKeySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.lang.ProcessEnvironment$StringKeySet$1 from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.integration.commandline.CommandLineUtils from file://liquibase.jar]
[Loaded java.text.DontCareFieldPosition from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.text.Format$FieldDelegate from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.text.DontCareFieldPosition$1 from /usr/local/openjdk-8/lib/rt.jar]/liquibase.jar]
[Loaded liquibase.configuration.core.DefaultsFileValueProvider from file://liquibase.jar]
[Loaded java.lang.invoke.LambdaForm$DMH/802243390 from java.lang.invoke.LambdaForm]
[Loaded liquibase.configuration.core.DefaultsFileValueProvider$$Lambda$55/702061917 from liquibase.configuration.core.DefaultsFileValueProvider]
[Loaded liquibase.util.SystemUtil from file://liquibase.jar]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$56/1771667101 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded liquibase.configuration.ConfigurationDefinition$ConvertedValueProvider from file://liquibase.jar]
[Loaded liquibase.resource.CompositeResourceAccessor from file://liquibase.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor from file://liquibase.jar]
[Loaded java.nio.file.InvalidPathException from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor$CloseChildWillCloseParentStream from file://liquibase.jar]
[Loaded java.util.zip.GZIPInputStream from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.resource.FileSystemResourceAccessor$1 from file://liquibase.jar]
[Loaded java.nio.file.FileSystems from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.nio.file.FileSystems$DefaultFileSystemHolder from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.nio.file.FileSystems$DefaultFileSystemHolder$1 from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.util.CollectionUtil from file://liquibase.jar]
[Loaded liquibase.integration.commandline.CommandLineResourceAccessor from file://liquibase.jar]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$57/510147134 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded liquibase.integration.commandline.LiquibaseCommandLine$$Lambda$58/341138954 from liquibase.integration.commandline.LiquibaseCommandLine]
[Loaded sun.security.provider.SecureRandom from /usr/local/openjdk-8/lib/rt.jar]
[Loaded sun.security.provider.SHA from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.pro.packaged.mz$3 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nc$2 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nb$2 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nb$2$1 from file://liquibase.jar]
[Loaded liquibase.pro.packaged.nc$2$1 from file://liquibase.jar]
[Loaded javax.crypto.CipherInputStream from /usr/local/openjdk-8/lib/jce.jar]
[Loaded java.lang.ProcessEnvironment$StringKeySet from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.lang.ProcessEnvironment$StringKeySet$1 from /usr/local/openjdk-8/lib/rt.jar]
[Loaded liquibase.integration.commandline.CommandLineUtils from file://liquibase.jar]
[Loaded java.text.DontCareFieldPosition from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.text.Format$FieldDelegate from /usr/local/openjdk-8/lib/rt.jar]
[Loaded java.text.DontCareFieldPosition$1 from /usr/local/openjdk-8/lib/rt.jar]

Any idea?

1 Like

we can close this ticket. the issue found incompatibility with our linux script that we are using to run liquibase application on container, particularly not compatible with bin/bash, so we are using bin/sh instead.

2 Likes