I am trying to make gradle + hibernate work. I did it with gradle + spring + hibernate, but this project is using ejb hibernate.
build.gradle
plugins {
// id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'org.liquibase.gradle' version '2.0.4'
}
...
repositories {
mavenCentral()
}
dependencies {
compile project(':xxx'),
...
liquibaseRuntime 'org.liquibase:liquibase-core:4.1.1'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:3.0.0'
liquibaseRuntime 'mysql:mysql-connector-java:8.0.22'
liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:4.1.1'
liquibaseRuntime sourceSets.main.runtimeClasspath
liquibaseRuntime sourceSets.main.output
liquibaseRuntime("ch.qos.logback:logback-core:1.2.3")
liquibaseRuntime("ch.qos.logback:logback-classic:1.2.3")
implementation('org.liquibase:liquibase-core:4.1.1')
}
def props = new Properties()
file("src/main/resources/liquibase.properties").withInputStream { props.load(it) }
diff.dependsOn assemble
diffChangeLog.dependsOn assemble
liquibase {
activities {
dev {
driver 'com.mysql.cj.jdbc.Driver'
changeLogFile props.getProperty("liquibase.changelog.main")
url 'jdbc:mysql://localhost:3306/demo2'
username 'xxx'
password 'xxx'
referenceDriver "liquibase.ext.hibernate.database.connection.HibernateDriver"
referenceUrl props.getProperty("liquibase.changelog.referenceUrl")
}
}
runList = 'dev'
}
...
liquibase.properties
liquibase.changelog.main=src/main/resources/db/changelog/db.changelog-master.groovy
liquibase.changelog.classpath=classpath:db/changelog/db.changelog-master.groovy
liquibase.changelog.referenceUrl=hibernate:ejb3:test?dialect=org.hibernate.dialect.MySQL5Dialect
I am able to execute update / generate / changelogSync, but not diffChangeLog. There I am getting the following:
15:18:42.772 [QUIET] [system.out] Starting Liquibase at 15:18:42 (version 4.1.1 #10 built at 2020-10-12 19:24+0000)
15:18:42.841 [ERROR] [system.err] [2020-10-22 15:18:42] INFO [liquibase.servicelocator] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringBeanDatabase could not be instantiated
15:18:42.842 [ERROR] [system.err] [2020-10-22 15:18:42] INFO [liquibase.servicelocator] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringPackageDatabase could not be instantiated
15:18:43.341 [ERROR] [system.err] [2020-10-22 15:18:43] INFO [liquibase.ext] Reading hibernate configuration hibernate:ejb3:test?dialect=org.hibernate.dialect.MySQL5Dialect
15:18:43.356 [ERROR] [system.err] log4j:WARN No appenders could be found for logger (org.jboss.logging).
15:18:43.356 [ERROR] [system.err] log4j:WARN Please initialize the log4j system properly.
15:18:43.356 [ERROR] [system.err] log4j:WARN See Apache log4j 1.2 - Frequently Asked Technical Questions for more info.
15:18:43.382 [QUIET] [system.out] Unexpected error running Liquibase: Unknown reason
15:18:43.382 [QUIET] [system.out] For more information, please use the --logLevel flag
15:18:43.384 [ERROR] [system.err] [2020-10-22 15:18:43] SEVERE [liquibase.integration] Unexpected error running Liquibase: Unknown reason
15:18:43.384 [ERROR] [system.err] liquibase.exception.DatabaseException: java.lang.NullPointerException
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:2041)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main.doMigration(Main.java:1487)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.lambda$child$0(Scope.java:160)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:169)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:159)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:138)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:222)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:226)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main$1.run(Main.java:360)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main$1.run(Main.java:193)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:169)
15:18:43.384 [ERROR] [system.err] at liquibase.Scope.child(Scope.java:145)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main.run(Main.java:193)
15:18:43.384 [ERROR] [system.err] at liquibase.integration.commandline.Main.main(Main.java:156)
15:18:43.384 [ERROR] [system.err] Caused by: java.lang.NullPointerException
15:18:43.384 [ERROR] [system.err] at liquibase.ext.hibernate.database.HibernateEjb3Database.buildMetadataFromPath(HibernateEjb3Database.java:59)
15:18:43.385 [ERROR] [system.err] at liquibase.ext.hibernate.database.HibernateDatabase.buildMetadata(HibernateDatabase.java:143)
15:18:43.385 [ERROR] [system.err] at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:83)
15:18:43.385 [ERROR] [system.err] at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:120)
15:18:43.385 [ERROR] [system.err] at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:140)
15:18:43.385 [ERROR] [system.err] at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
15:18:43.385 [ERROR] [system.err] … 15 more
15:18:43.385 [ERROR] [system.err]