Skip to Main Content

SQLcl

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Using SQLcl Liquibase Functionality with liquibase-maven-plugin

Alf LervågMar 18 2025

I'm trying to wire up our liquibase changelogs with our maven-based build process. In theory this should be possible, and it's even partly documented by Oracle: https://docs.oracle.com/en/database/oracle/sql-developer-command-line/24.4/sqcug/using-sqlcl-liquibase-functionality-open-source-liquibase.html

Unfortunately, it seems that this documentation is based on how things were in SQLcl versions up to 23.4. From this point on, there is no liquibase.changelog.visitor.OracleActionChangeListener-class. This corresponds with an upgrade of liquibase-core from 4.18.0 → 4.24.0. From what I can understand, the newer versions of SQLcl Liquibase uses ServiceLoaders and thus there is no longer a need to configure the change-exec-listener-class manually.

I've been able to set things up so that it almost works, but when I try to add a sql-formatted changelog to my root changelog, it blows up with a NullPointerException (see build.log for the entire maven output and stacktrace):

Caused by: java.lang.NullPointerException: Cannot invoke "oracle.dbtools.raptor.liquibase.core.ActiveCommand.getActiveConn()" because the return value of "oracle.dbtools.raptor.liquibase.configuration.SqlclConfig.getCommand()" is null
    at oracle.dbtools.raptor.liquibase.util.LbUtils.getLbConnection (LbUtils.java:383)
    at oracle.dbtools.raptor.liquibase.executor.jvm.SqlClExecutor.execute (SqlClExecutor.java:137)

As far as I can see, the problem is that oracle.dbtools.raptor.liquibase.executor.jvm.SqlClExecutor attempts to expand %USER_NAME% in the SQL statements before running them. To find the username liquibase is running with, it tries to find the Liquibase Database Connection in the SqlclConfig. Unfortunately, this has not been set up correctly. Since SqlClExecutor inherits from JdbcExecutor I believe it would be better to fetch the Liquibase Database Connection from the protected field database inherited from there instead: database.getConnection().

Of course, it's likely that I'm missing some configuration or dependency that makes sure that the SqlclConfig gets set up correctly before this code runs. If that is the case, I would very much like to get some help with this.

Yours,
Alf Lervåg
Sikt

Comments

Post Details

Added on Mar 18 2025
2 comments
65 views