Error Looks Like Following
[2024-02-08 10:57:43] INFO [liquibase.command] Command execution complete
[2024-02-08 10:57:43] SEVERE [liquibase.integration] class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
liquibase.exception.CommandExecutionException: java.lang.ClassCastException: class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
at liquibase.command.CommandScope.execute(CommandScope.java:253)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
at picocli.CommandLine.execute(CommandLine.java:2170)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:391)
at liquibase.Scope.child(Scope.java:195)
at liquibase.Scope.child(Scope.java:171)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:366)
at liquibase.Scope.child(Scope.java:195)
at liquibase.Scope.child(Scope.java:171)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:363)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:103)
Caused by: java.lang.ClassCastException: class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
at liquibase.command.CommandScope.logPrimaryExceptionToMdc(CommandScope.java:287)
at liquibase.command.CommandScope.execute(CommandScope.java:245)
... 18 more
Unexpected error running Liquibase: class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
liquibase.exception.CommandExecutionException: java.lang.ClassCastException: class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
at liquibase.command.CommandScope.execute(CommandScope.java:253)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
at picocli.CommandLine.execute(CommandLine.java:2170)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$2(LiquibaseCommandLine.java:391)
at liquibase.Scope.child(Scope.java:195)
at liquibase.Scope.child(Scope.java:171)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$3(LiquibaseCommandLine.java:366)
at liquibase.Scope.child(Scope.java:195)
at liquibase.Scope.child(Scope.java:171)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:363)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:103)
Caused by: java.lang.ClassCastException: class java.lang.Throwable cannot be cast to class java.lang.Exception (java.lang.Throwable and java.lang.Exception are in module java.base of loader 'bootstrap')
at liquibase.command.CommandScope.logPrimaryExceptionToMdc(CommandScope.java:287)
at liquibase.command.CommandScope.execute(CommandScope.java:245)
... 18 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':diffChangelog
build.gradle looks like
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.liquibase.gradle' version '2.2.1'
}
//our own config for running liquibase diff
//apply from: 'gradle/liquibase.gradle'
//apply plugin: "org.liquibase.gradle"
group = 'com.prismhr.api'
version = '1.0.0'
java {
sourceCompatibility 17
targetCompatibility 17
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation 'com.prismhr.api:prismApi-common:1.0.0'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'javax.validation:validation-api'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework:spring-tx'
liquibaseRuntime 'org.liquibase:liquibase-core:4.25.1'
liquibaseRuntime "org.liquibase.ext:liquibase-hibernate6:4.25.1"
// liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.1.1'
liquibaseRuntime sourceSets.main.runtimeClasspath
liquibaseRuntime sourceSets.main.output
liquibaseRuntime 'info.picocli:picocli:4.7.5'
liquibaseRuntime 'org.yaml:snakeyaml:2.0'
liquibaseRuntime 'org.postgresql:postgresql'
}
//with the new Spring boot version 2.5.4 bootJar and jar was running to create two snapshot version,
// resulting in docker failure, need to specifically set jar to false to make sure to not get SNAPSHOT-plain.jar
jar {
enabled = false
}
liquibase {
activities {
main {
changeLogFile "src/main/resources/db/changelog/" + (new Date()).format('yyyyMMdd_HHmmss') + "_changelog.xml"
referenceUrl 'hibernate:spring:com.prismhr.api.generalledger.domain?dialect=org.hibernate.dialect.PostgreSQLDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
url "jdbc:postgresql://localhost:5432/postgres?currentSchema=myschema&INIT=CREATE SCHEMA IF NOT EXISTS myschema"
username "postgres"
password "mysecretpassword"
driver "liquibase.ext.hibernate.database.connection.HibernateDriver"
logLevel "debug"
}
}
}
//configurations.configureEach {
// exclude module: 'slf4j-log4j12'
//}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
}
test {
useJUnitPlatform()
}
all db details sent in application.yaml are correct i can see this exception whenever I try to run diffchangelog command.
Please help me out.