-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command line arguments don't seem to be passed to the Liquibase CLI when using the v3.0.0 plugin #154
Comments
@stevesaliman you appear to be the core maintainer, so just tagging you here :). |
Thank you for the test project, it is very helpful because I now have something that fails on my system :-) There are a couple of things going on there that I'm trying to chase down... First of all, the groovy DSL should work the same with Kotlin as it does with groovy, so no issue there. The DSL does expect camelCase arguments, so you'll want to update the build file to use Second, if you add The thrid thing is the real head scratcher. If I run However If I add |
I had the same issue, and starting with
There seems to be an issue detecting the supported command arguments starting with Liquibase version 4.27.0. The release notes don't contain any suspicious changes. |
@stevesaliman sorry for the late reply, just returning from an extra long weekend. Thanks so much for looking into this. That is so weird, regarding debug output affecting its behavior. Honestly I probably won't have much time to debug this code to figure out why it thinks these args are unsupported, but I'll see if I can slice out some time. In the meanwhile, I'll see if the workaround with |
Here is how I'm using it in Kotlin and I'm encountering similar issues: // build.gradle.kts
liquibase {
jvmArgs = "-Duser.dir=$projectDir"
runList = "main"
activities.register("main") {
this.arguments =
mapOf(
"changelogFile" to "src/main/resources/db/changelog/build-changelog.yaml",
"url" to "jdbc:postgresql://localhost:5433/postgres",
"username" to "pguser",
"password" to "pguser",
)
}
} Logs:
I'm also noticing this behavior as the commands work when running with the debugger, but fail without the debugger. |
I'm facing the same behavior using groovy. I followed the instructions in Usage. I created a project from Spring Starter Project in STS. I'm using JAVA 17 and Gralde 8.8. The dependencies versions are explicited in build.gradle. You may see the build.gradle content here: buildscript {
dependencies {
classpath 'org.liquibase:liquibase-core:4.27.0' //I don't know why, but it is necessary to command line finds the classes
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.liquibase.gradle' version '3.0.0'
}
group = 'br.subscribe'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
liquibaseRuntime.extendsFrom runtime
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.liquibase:liquibase-core:4.27.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'mysql:mysql-connector-java:5.1.34'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
liquibaseRuntime 'org.liquibase:liquibase-core:4.27.0'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:3.0.2'
liquibaseRuntime 'info.picocli:picocli:4.6.1'
liquibaseRuntime 'com.h2database:h2'
liquibaseRuntime 'mysql:mysql-connector-java:5.1.34'
liquibaseRuntime 'javax.xml.bind:jaxb-api:2.3.1'
liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:3.6'
liquibaseRuntime 'ch.qos.logback:logback-core:1.2.3'
liquibaseRuntime 'ch.qos.logback:logback-classic:1.2.3'
liquibaseRuntime sourceSets.main.output
}
if(!project.hasProperty('runList')){
project.ext.runList = 'main'
}
project.ext.diffChangelogFile = '${buildDir}/' + new Date().format('yyyyMMddHHmmss') + '_changelog.xml'
liquibase {
activities {
main {
driver 'org.h2.Driver'
url 'jdbc:h2:file:./h2db/subscribe_db;DB_CLOSE_DELAY=-1;AUTO_SERVER=true;MODE=MYSQL;'
username 'sa'
password ' '
changelogFile 'src/main/resources/db/changelog/master.xml'
logLevel 'debug'
}
diffLog {
driver 'org.h2.Driver'
url 'jdbc:h2:file:./h2db/subscribe_db;DB_CLOSE_DELAY=-1;AUTO_SERVER=true;MODE=MYSQL;'
username 'sa'
password ' '
changelogFile project.ext.diffChangelogFile
referenceUrl 'hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect'
logLevel 'debug'
}
}
runList = project.ext.runList
}
tasks.named('test') {
useJUnitPlatform()
} You also may see the application.yaml content here: spring:
application:
name: api-subscribe
################################
# H2 Database (DEV)
################################
---
spring:
h2:
console:
enabled: true
path: /h2-console
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:file:./h2db/subscribe_db;DB_CLOSE_DELAY=-1;AUTO_SERVER=true;MODE=MYSQL;
username: sa
password:
################################
# LIQUIBASE
################################
---
spring:
liquibase:
changeLog: 'classpath:/db/changelog/master.xml' The error occours when i run the command line: gradlew diffChangeLog -PrunList=diffLog
> Task :diffChangelog
liquibase-plugin: Running the 'diffLog' activity...
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:33:21 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
Liquibase Version: 4.27.0
WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
Error parsing command line: Invalid argument '--changelog-file': missing required argument. If you need to configure new liquibase project files and arguments, run the 'liquibase init project' command.
For detailed help, try 'liquibase --help' or 'liquibase <command-name> --help'
> Task :diffChangelog FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':diffChangelog'.
> Process 'command 'C:\Program Files\Java\jdk-17.0.1\bin\java.exe'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 6s
1 actionable task: 1 executed Anyone can help me to find what's wrong in those configurations ? |
I think I may have figured out what is going on. I'll add details to the issue if my hunch proves correct. I pushed an update to the code, but I haven't released a new version yet. @marques-work @timrs2998 @daniloalexandre can you build a local version of the plugin and see if the latest code solves your issues? You can publish the 3.0.1-SNAPSHOT of the plugin to a local repo with the buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
} The key is to see how the plugin calls Liquibase. If you with Running 'liquibase --driver=org.postgresql.Driver --search-path=/home/steve/projects/tmp/liquibase-gradle-3.0.0-test/src/main/resources update --changelog-file=changelog.xml --password=12345 --url=jdbc:postgresql://localhost:6432/postgres --username=1234' If not, it will just say Running 'liquibase update', with no arguments. |
@stevesaliman thanks for the quick fix -- it works! I do have some updated instructions for others trying to test fix because the instructions listed above didn't work for me. Testing the locally built plugin: how to get this to workBuilding the pluginI'm using JDK 21 by default, so if you are too, building the new plugin version won't work because it's not compatible with Gradle 7 (used by the plugin). I'm using Resolving the newly built snapshotFor me, the
Important Note the weird artifact ID! Anyway, I hacked it to work so here's the combination that worked for me: Under pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.liquibase.gradle") {
useModule("org.liquibase:liquibase-gradle-plugin:3.0.1-SNAPSHOT")
}
}
}
} I didn't need to add anything to the Once I did that, I could build my project. After that, worked like a charm! I can now see my migration in the |
@stevesaliman once you tag/release a new version, please close this issue as you see fit. Thanks again! |
@stevesaliman sorry I made an incorrect comment (now deleted) earlier about it still not working, but that was my mistake. I'm not sure what happened but I can't reproduce it anymore. Sorry for the false alarm. It seems to work just fine, with or without the debug log setting. |
@stevesaliman , thank's for the quick answer. Sorry, but it's still failing to me. I did the same workaround from @marques-work that forces the gradlew recognizes the 3.0.1-SNAPSHOT version: see the settings.gradle: pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.liquibase.gradle") {
useModule("org.liquibase:liquibase-gradle-plugin:3.0.1-SNAPSHOT")
}
}
}
}
rootProject.name = 'api-subscribe' The only change in build.gradle file was the plugin's version: plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.liquibase.gradle' version '3.0.1-SNAPSHOT'
} However, the same issue persists. Looking at the logs, using '--debug' argument, we can see the liquibase running without arguments: ...
2024-09-09T09:50:27.962-0300 [QUIET] [system.out] liquibase-plugin: Running the 'diffLog' activity...
2024-09-09T09:50:27.962-0300 [DEBUG] [org.gradle.api.Project] liquibase-plugin: The liquibase.integration.commandline.LiquibaseCommandLine class will be used to run Liquibase
2024-09-09T09:50:27.962-0300 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Liquibase will be run with the following jvmArgs: []
2024-09-09T09:50:27.962-0300 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Running 'liquibase diff-changelog'
...
Error parsing command line: Invalid argument '--changelog-file': missing required argument. If you need to configure new liquibase project files and arguments, run the 'liquibase init project' command. |
@daniloalexandre did you try running without daemons? I wonder if that matters. For me, I killed any leftover gradle daemons when I ran. FWIW, I thought I saw an error like yours too after the update, but it went away after i killed all daemons, tore down my containers, ran |
Hi, @marques-work , thanks for your help. When I run the command ERROR: Exception Primary Reason: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect) I have no idea why this is happening, because there's a liquibase parameter configured with the driver. =/ driver 'org.h2.Driver' here is the full log: To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.8/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :diffChangelog
liquibase-plugin: Running the 'diffLog' activity...
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 20:39:51 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
[2024-09-09 20:39:51] INFO [liquibase.ui] ####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 20:39:51 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
Liquibase Version: 4.27.0
[2024-09-09 20:39:51] INFO [liquibase.ui] Liquibase Version: 4.27.0
WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-09-09 20:39:51] INFO [liquibase.ui] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-09-09 20:39:51] INFO [liquibase.integration] Starting command execution.
[2024-09-09 20:39:52] INFO [liquibase.command] Logging exception.
ERROR: Exception Details
[2024-09-09 20:39:52] INFO [liquibase.ui] ERROR: Exception Details
ERROR: Exception Primary Class: RuntimeException
[2024-09-09 20:39:52] INFO [liquibase.ui] ERROR: Exception Primary Class: RuntimeException
ERROR: Exception Primary Reason: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
[2024-09-09 20:39:52] INFO [liquibase.ui] ERROR: Exception Primary Reason: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
ERROR: Exception Primary Source: 4.27.0
[2024-09-09 20:39:52] INFO [liquibase.ui] ERROR: Exception Primary Source: 4.27.0
[2024-09-09 20:39:52] INFO [liquibase.command] Command execution complete
[2024-09-09 20:39:52] SEVERE [liquibase.integration] Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.command.CommandScope.execute(CommandScope.java:257)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:395)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:370)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:367)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:104)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.command.core.helpers.AbstractDatabaseConnectionCommandStep.createDatabaseObject(AbstractDatabaseConnectionCommandStep.java:105)
at liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep.obtainDatabase(ReferenceDbUrlConnectionCommandStep.java:89)
at liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep.run(ReferenceDbUrlConnectionCommandStep.java:70)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
... 17 more
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:241)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:188)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:153)
at liquibase.command.core.helpers.AbstractDatabaseConnectionCommandStep.createDatabaseObject(AbstractDatabaseConnectionCommandStep.java:73)
... 20 more
Caused by: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.database.DatabaseFactory.findDriverClass(DatabaseFactory.java:291)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:224)
... 23 more
Unexpected error running Liquibase: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.command.CommandScope.execute(CommandScope.java:257)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:395)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:370)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:367)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:104)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.command.core.helpers.AbstractDatabaseConnectionCommandStep.createDatabaseObject(AbstractDatabaseConnectionCommandStep.java:105)
at liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep.obtainDatabase(ReferenceDbUrlConnectionCommandStep.java:89)
at liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep.run(ReferenceDbUrlConnectionCommandStep.java:70)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
... 17 more
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:241)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:188)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:153)
at liquibase.command.core.helpers.AbstractDatabaseConnectionCommandStep.createDatabaseObject(AbstractDatabaseConnectionCommandStep.java:73)
... 20 more
Caused by: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect)
at liquibase.database.DatabaseFactory.findDriverClass(DatabaseFactory.java:291)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:224)
... 23 more
> Task :diffChangelog FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':diffChangelog'.
> Process 'command 'C:\Program Files\Java\jdk-17.0.1\bin\java.exe'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 25s
1 actionable task: 1 executed
|
@daniloalexandre never seen that happen before. I wonder if the problem is really the connection URL? Have you just tried a standard H2 JDBC url, like |
If you run gradle with --debug, and the plugin is running liquibase with all the right arguments, as described in a previous comment, then the issue probably lies in Liquibase itself, and not the plugin. The fact that "the liquibase parameters are found" is a good sign :-) Are you specifying a driver class, or just defining a URL? Is there a "--driver=some.class" being passed to Liquibase itself? |
Yes for all quetions. =) 2024-09-10T10:29:40.472-0300 [DEBUG] [org.gradle.api.Project] liquibase-plugin: Running 'liquibase --driver=org.h2.Driver --log-level=info diff-changelog --changelog-file=${buildDir}/20240910102936_changelog.xml --password= --reference-url=hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.H2Dialect --url=jdbc:h2:file:./h2db/subscribe_db;DB_CLOSE_DELAY=-1;AUTO_SERVER=true;MODE=MYSQL; --username=sa'
|
@daniloalexandre, I'm not sure what is happening in your case, but the debug output looks like the plugin is calling Liquibase correctly, so I don't think this is a pugin issue. Since you and others are reporting that Liquibse is being called correctly now, I've released 3.0.1, and I'm closing this issue. |
The 3.0.0 release had a classpath related bug that caused liquibase to fail in most cases. This was fixed in version 3.0.1. See liquibase/liquibase-gradle-plugin#151 and liquibase/liquibase-gradle-plugin#154
The 3.0.0 release had a classpath related bug that caused liquibase to fail in most cases. This was fixed in version 3.0.1. See liquibase/liquibase-gradle-plugin#151 and liquibase/liquibase-gradle-plugin#154
Based on some of the comments from @marques-work and @daniloalexandre, and my own experiences, I think the 3.0.1 fix works most of the time, but not always for some reason. It will work probably 80-90% of the time, then periodically fail out with the I keyed in on one of @stevesaliman's comments above about what is output by the We are using Groovy for our build.gradle file and not using Kotlin at all in the project. I'm noting this because the others seemed to be using Kotlin Gradle files. If there's any additional information I can provide please let me know. A co-worker was also able to replicate the behavior on their machine after some tries.
|
As @awhitmer-df mentioned, it's also happening for me sporadically with 3.0.1. What I've found though is that the moment you stop the gradle daemon ( |
I'm doing some tests here too. I found that in debug mode it works like a charm, but it doesn`t work when running normally. I think it looks like having something with threads and memory sharing. The args are not being passed to the liquibase command, but when I debug it to see whats is happening, it works. |
@stevesaliman as others have reported, I do see this on occasion, but it seems to go away after killing daemons and retrying. I wonder if multiple gradle daemons are present if only one of them works because of some state that is set on initial run. Like @rafaeljpc suggested, this intermittent behavior looks consistent with threads and memory issues. Luckily for my team, the gradle plugin is a localdev convenience and not critical for deployment, but others may be blocked by this. That said, maybe a proposed workaround is to use To others here: as this issue is closed (and I'm not able to reopen it), you might get more traction if you open a new issue and report these intermittent failures. |
Created #157 |
Hi, @stevesaliman and @marques-work . Sorry for later answer. I was working on several changes in project and now I'm back for this issue. The project currently uses Postgres datasource connection and I changed my liquibase activities as follow: liquibase {
activities {
main {
driver 'org.postgresql.Driver'
url 'jdbc:postgresql://localhost:5432/subscribe_db'
username 'postgres'
password 'postgres'
defaultSchemaName 'subscribe'
changelogFile 'src/main/resources/db/changelog/master.xml'
logLevel 'info'
}
diffLog {
driver 'org.postgresql.Driver'
url 'jdbc:postgresql://localhost:5432/subscribe_db'
username 'postgres'
password 'postgres'
defaultSchemaName 'subscribe'
schemas 'subscribe'
changelogFile project.ext.diffChangelogFile
referenceUrl 'hibernate:spring:br.subscribe.domain?dialect=org.hibernate.dialect.PostgreSQLDialect'
referenceDriver 'liquibase.ext.hibernate.database.connection.HibernateDriver'
referenceDefaultSchemaName 'subscribe'
referenceSchemas 'subscribe'
logLevel 'info'
}
}
runList = project.ext.runList
} I noticed that 'referenceDriver' is needed to avoid the error:
After that, when I'm using--no-daemon, the liquibase task "update" works properly. But, when I try to execute the task 'diffChangeLog': gradlew diffChangelog -PrunList=diffLog --no-daemon the follow error occurs: WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-10-12 13:38:31] INFO [liquibase.ui] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-10-12 13:38:31] INFO [liquibase.integration] Starting command execution.
[2024-10-12 13:38:32] WARNING [liquibase.database] Unknown database: Hibernate
[2024-10-12 13:38:32] WARNING [liquibase.command] Ignoring the global liquibase.driver value in favor of the command value.
[2024-10-12 13:38:32] INFO [liquibase.database] Error getting default schema
java.lang.NullPointerException: Cannot invoke "java.sql.CallableStatement.executeQuery()" because "cs" is null
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:585)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:136)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:224)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:235)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:243)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:258)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:253)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:354)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:311)
at liquibase.CatalogAndSchema.standardize(CatalogAndSchema.java:87)
at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:140)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:180)
at liquibase.command.core.DiffCommandStep.generateDatabaseShapshot(DiffCommandStep.java:205)
at liquibase.command.core.DiffCommandStep.createReferenceSnapshot(DiffCommandStep.java:192)
at liquibase.command.core.DiffCommandStep.createDiffResult(DiffCommandStep.java:113)
at liquibase.command.core.DiffCommandStep.run(DiffCommandStep.java:89)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:395)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:370)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:367)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:104)
[2024-10-12 13:38:32] INFO [liquibase.database] Error getting default schema
java.lang.NullPointerException: Cannot invoke "java.sql.CallableStatement.executeQuery()" because "cs" is null
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:585)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:136)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:224)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:235)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:243)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:258)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:253)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:354)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:311)
at liquibase.CatalogAndSchema.standardize(CatalogAndSchema.java:100)
at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:140)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:180)
at liquibase.command.core.DiffCommandStep.generateDatabaseShapshot(DiffCommandStep.java:205)
at liquibase.command.core.DiffCommandStep.createReferenceSnapshot(DiffCommandStep.java:192)
at liquibase.command.core.DiffCommandStep.createDiffResult(DiffCommandStep.java:113)
at liquibase.command.core.DiffCommandStep.run(DiffCommandStep.java:89)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:395)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:370)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:367)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:104)
[2024-10-12 13:38:32] INFO [liquibase.snapshot] Creating snapshot
[2024-10-12 13:38:32] WARNING [liquibase.snapshot] Unable to retrieve the list of catalog names from the database metadata
[2024-10-12 13:38:33] INFO [liquibase.command] Logging exception.
ERROR: Exception Details
[2024-10-12 13:38:33] INFO [liquibase.ui] ERROR: Exception Details
ERROR: Exception Primary Class: NullPointerException
[2024-10-12 13:38:33] INFO [liquibase.ui] ERROR: Exception Primary Class: NullPointerException
ERROR: Exception Primary Reason: Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null
[2024-10-12 13:38:33] INFO [liquibase.ui] ERROR: Exception Primary Reason: Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null
ERROR: Exception Primary Source: PostgreSQL 15.5
[2024-10-12 13:38:33] INFO [liquibase.ui] ERROR: Exception Primary Source: PostgreSQL 15.5
[2024-10-12 13:38:33] INFO [liquibase.command] Command execution complete
[2024-10-12 13:38:33] SEVERE [liquibase.integration] Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null
liquibase.exception.CommandExecutionException: java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null
at liquibase.command.CommandScope.execute(CommandScope.java:257)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:395)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:370)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:175)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:367)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:104)
Caused by: java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null
at liquibase.snapshot.jvm.SchemaSnapshotGenerator.getDatabaseSchemaNames(SchemaSnapshotGenerator.java:129)
at liquibase.snapshot.jvm.SchemaSnapshotGenerator.snapshotObject(SchemaSnapshotGenerator.java:63)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:65)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:68)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:68)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:68)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:313)
at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:106)
at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:59)
at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:38)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:214)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:187)
at liquibase.command.core.DiffCommandStep.generateDatabaseShapshot(DiffCommandStep.java:205)
at liquibase.command.core.DiffCommandStep.createReferenceSnapshot(DiffCommandStep.java:192)
at liquibase.command.core.DiffCommandStep.createDiffResult(DiffCommandStep.java:113)
at liquibase.command.core.DiffCommandStep.run(DiffCommandStep.java:89)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
... 17 more
Unexpected error running Liquibase: Cannot invoke "java.sql.ResultSet.next()" because "schemas" is null As you can see on diffLog activity, I declare the properties 'defaultSchemaName', 'schemas', 'referenceDefaultSchemaName' and 'referenceSchemas'. What I missing? |
We're having trouble upgrading the gradle plugin from
v2.2.2
tov3.0.0
in our Kotlin project.Not sure if the Kotlin Gradle DSL is the exact issue or if I'm just doing something stupid and aren't understanding the upgrade instructions. All the examples are using the Groovy DSL, so I'm not ruling it out. While our project is a multi-project/submodule setup (I read the note about setting
-Duser.dir
) I see the same behavior in a single root module setup as well.I've tried my best to distill this in a reproducible test project: https://github.com/marques-work/liquibase-gradle-3.0.0-test
Anyhow, according to the output, it doesn't seem like any command-line args are being set at all. I'm setting the following basic args:
changelog-file
search-path
url
driver
username
password
No arguments are being passed to the
update
command according to debug output. I keep getting this missing--changelog-file
argument error.I've tried variations of this in the
Map
configured in theliquibase { ... }
block, such as:--changelog-file
changlog-file
changelogfile
changelogFile
(as in the docs)changeLogFile
(not supposed to work in the new version, but tried for good measure anyway)At this point, I've given up and am reaching out for help. Yes, I've added the
buildscript
block with theclasspath
dependencies. I'm using the latestliquibase
version andpicocli
version as of today (4.29.1
and4.7.6
, respectively).If you could look at the repo I linked above, I think the instructions are pretty clear. In summary, the
main
branch is a working example usingv2.2.2
of the plugin. Theupgrade
branch is the broken project usingv3.0.0
.Please tell me what I'm doing wrong (or if this is a real bug, help me understand and maybe guide me to submit a bugfix PR).
The text was updated successfully, but these errors were encountered: