question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to run diffChangeLog with spring boot with java 11

See original GitHub issue

Hello. I am unable to get this running for my project on java 11 with spring boot. My build.gradle:

buildscript {
	ext {
		springBootVersion = '2.1.0.RELEASE'
        runList = 'main'
        diffLog = '$projectDir/src/main/resources/db/changelog/db.changelog-master.xml'
    }
	repositories {
        mavenLocal()
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath 'org.liquibase:liquibase-gradle-plugin:2.0.1'
//        classpath 'org.liquibase:liquibase-core'
        classpath 'org.liquibase:liquibase:3.7.0-SNAPSHOT'
        classpath 'org.postgresql:postgresql:42.2.5'
        classpath 'org.liquibase.ext:liquibase-hibernate5:3.6'
        classpath 'org.springframework.data:spring-data-jpa:2.1.2.RELEASE'
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.liquibase.gradle'


group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 11.0
diffLog = '$projectDir/src/main/resources/db/changelog/db.changelog-{$version}.xml'


repositories {
    mavenLocal()
	mavenCentral()
}


dependencies {
	implementation('org.springframework.boot:spring-boot-starter-data-jpa')
	implementation('org.springframework.boot:spring-boot-starter-security')
	implementation('org.springframework.boot:spring-boot-starter-webflux')
	implementation('org.springframework.session:spring-session-core')
	implementation('org.liquibase.ext:liquibase-hibernate5:3.6')
//	implementation('org.liquibase:liquibase-core:3.6.2')
    implementation('org.liquibase:liquibase:3.7.0-SNAPSHOT')
    implementation('io.reactivex.rxjava2:rxjava:2.2.3')
	implementation("org.hsqldb:hsqldb:2.4.1")
  	implementation("org.postgresql:postgresql:42.2.5")
    compileOnly('org.projectlombok:lombok:1.18.4')

	testImplementation('org.springframework.boot:spring-boot-starter-test')
	testImplementation('io.projectreactor:reactor-test')
	testImplementation('org.springframework.security:spring-security-test')

    liquibaseRuntime('org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE')
    liquibaseRuntime('org.liquibase.ext:liquibase-hibernate5:3.6')
//    liquibaseRuntime('org.liquibase:liquibase-core:3.6.2')
    liquibaseRuntime('org.liquibase:liquibase:3.7.0-SNAPSHOT')
    liquibaseRuntime("org.postgresql:postgresql:42.2.5")
    liquibaseRuntime("javax.xml.bind:jaxb-api:2.3.1")
    liquibaseRuntime sourceSets.main.output
}

diff.dependsOn compileJava
diffChangeLog.dependsOn compileJava

liquibase {
    activities {
        main {
            changeLogFile project.ext.diffLog
            driver 'org.postgresql.Driver'
            url 'jdbc:postgresql://localhost:5432/database'
            username 'username'
            password 'password'
            referenceUrl 'hibernate:spring:com.company.warehouse.db?' +
                    'dialect=org.hibernate.dialect.PostgreSQL94Dialect&' +
                    'hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&' +
                    'hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
//            referenceDriver 'liquibase.ext.hibernate.database.connection.HibernateDriver'
        }
        runList = project.ext.runList
    }
}

When running either diff or diffChangeLog, I am getting this:

Unexpected error running Liquibase: java.lang.NullPointerException
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
	at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:200)
	at liquibase.integration.commandline.Main.doMigration(Main.java:1004)
	at liquibase.integration.commandline.Main.lambda$run$0(Main.java:187)
	at liquibase.Scope.child(Scope.java:125)
	at liquibase.Scope.child(Scope.java:106)
	at liquibase.Scope.child(Scope.java:138)
	at liquibase.Scope.child(Scope.java:142)
	at liquibase.integration.commandline.Main.run(Main.java:186)
	at liquibase.integration.commandline.Main.main(Main.java:125)
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
	at liquibase.command.AbstractCommand.execute(AbstractCommand.java:24)
	at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:198)
	... 8 common frames omitted
Caused by: java.lang.NullPointerException: null
	at liquibase.snapshot.jvm.JdbcSnapshotGenerator.getDatabaseCatalogNames(JdbcSnapshotGenerator.java:147)
	at liquibase.snapshot.jvm.CatalogSnapshotGenerator.snapshotObject(CatalogSnapshotGenerator.java:34)
	at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:66)
	at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
	at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:286)
	at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:96)
	at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:59)
	at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:38)
	at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:215)
	at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:188)
	at liquibase.command.core.DiffCommand.createReferenceSnapshot(DiffCommand.java:221)
	at liquibase.command.core.DiffCommand.createDiffResult(DiffCommand.java:143)
	at liquibase.command.core.DiffCommand.run(DiffCommand.java:135)
	at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19)
	... 9 common frames omitted

This is caused by HibernateConnectionMetadata class, which I do not understand the purpose of. It just returns null/0/false for everything. So then I tried commenting out referenceDriver 'liquibase.ext.hibernate.database.connection.HibernateDriver' and replaced the line with: driver 'org.postgresql.Driver' But that amounted to getting a new exception instead:

Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:sk.imuna.warehouse.db?dialect=org.hibernate.dialect.PostgreSQL94Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy)
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:sk.imuna.warehouse.db?dialect=org.hibernate.dialect.PostgreSQL94Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy)
	at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
	at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1407)
	at liquibase.integration.commandline.Main.doMigration(Main.java:1005)
	at liquibase.integration.commandline.Main.lambda$run$0(Main.java:187)
	at liquibase.Scope.child(Scope.java:125)
	at liquibase.Scope.child(Scope.java:106)
	at liquibase.Scope.child(Scope.java:138)
	at liquibase.Scope.child(Scope.java:142)
	at liquibase.integration.commandline.Main.run(Main.java:186)
	at liquibase.integration.commandline.Main.main(Main.java:125)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:sk.imuna.warehouse.db?dialect=org.hibernate.dialect.PostgreSQL94Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:247)
	at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:142)
	at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
	... 9 common frames omitted
Caused by: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:sk.imuna.warehouse.db?dialect=org.hibernate.dialect.PostgreSQL94Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:193)
	... 11 common frames omitted

No idea what that means since postgre driver is clearly listed as a liquibaseRuntime dependency. This may not be an issue of this project, I am rather looking for an advice how to proceed.

┆Issue is synchronized with this Jira Bug by Unito

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
muasifcommented, Jun 6, 2019

I am getting the same error. It is like the catalogs object is coming as null when I am using it with the MySQL database

image

Any help?

0reactions
Syndlexcommented, May 31, 2021

I had this Problem: I defined the ref URL in the liquibase.properties file. And put a Multiline string there.

referenceUrl:"hibernate:spring:de.cop.business.model\
  ?dialect=org.hibernate.dialect.SQLServerDialect"

I forgot that Properties is not yaml and " is invalid.

Removing the " worked. Parsing the URI should really be validated before executing on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run diffChangeLog with spring boot with java 11 #54
Hello. As instructed in #44 , I am opening a new issue here. Not sure if this a proper issue, and as was...
Read more >
LiquiBase diff & diffChangeLog doesn't detect changes
You have to let hibernate/jpa/else generate the schema and then use diffChangeLog command. This allows you to generate a changeset file. It ...
Read more >
Use Liquibase to Safely Evolve Your Database Schema
In this quick tutorial, we'll make use of Liquibase to evolve the database schema of a Java web application. We'll look at a...
Read more >
Unable to Start Spring boot Server - Flowable Forum
I am not able to start Spring Boot Server . Getting following error : type or paste code here Caused by: liquibase.exception.
Read more >
[ERROR] Failed to execute goal org ... - Liquibase Forum
... in liquibase and I want to make a test project using spring boot, ... [ERROR] Failed to execute goal ... <java.version>11</java.version>
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found