liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
199 stars 59 forks source link

NullPointerException after updatng Liquibase to 4.2.0 #80

Closed JanCizmar closed 3 years ago

JanCizmar commented 3 years ago

I am getting following error after updating liquibase to 4.2.0. Is this plugin compatible with it?

[2020-12-05 13:03:38] SEVERE [liquibase.integration] Unexpected error running Liquibase: Unknown reason
liquibase.exception.DatabaseException: java.lang.NullPointerException
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
    at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:2046)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1480)
    at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
    at liquibase.Scope.lambda$child$0(Scope.java:160)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:159)
    at liquibase.Scope.child(Scope.java:138)
    at liquibase.Scope.child(Scope.java:222)
    at liquibase.Scope.child(Scope.java:226)
    at liquibase.integration.commandline.Main$1.run(Main.java:360)
    at liquibase.integration.commandline.Main$1.run(Main.java:193)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:145)
    at liquibase.integration.commandline.Main.run(Main.java:193)
    at liquibase.integration.commandline.Main.main(Main.java:156)
Caused by: java.lang.NullPointerException
    at liquibase.database.core.CockroachDatabase.isCorrectDatabaseImplementation(CockroachDatabase.java:36)
    at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:100)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:140)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
    ... 15 more

I am using this configuration:

def liveDb = [
        url         : 'jdbc:postgresql://localhost:5432/postgres',
        referenceUrl: 'hibernate:spring:io.polygloat' +
                '?dialect=org.hibernate.dialect.PostgreSQL95Dialect' +
                '&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy' +
                '&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy',
        username    : 'postgres',
        password    : 'postgres',
]

liquibase {
    activities {
        main {
            changeLogFile 'src/main/resources/db/changelog/schema.xml'
            url liveDb.url
            referenceUrl liveDb.referenceUrl
            username liveDb.username
            password liveDb.password
            driver "org.postgresql.Driver"
        }
    }
}

It seems like liquibase.database.jvm.JdbcConnection#createStatement() returns null for some reason.

Thanks for any help. :)

stevesaliman commented 3 years ago

I don't see any obvious changes that would make the plugin break with version 4.2.2. I did a test on one of my projects that uses MariaDB and Liquibase 4.2.2 and it ran dropAll and update just fine. What command are you running?

I don't think that createStatement is returning null, I think the connection that gets passed in is null, causing the NPE when it tries to invoke createStatement.

Which makes me think it has something to do with the credentials, or maybe the Postgres driver is not being found in the classpath, but that wouldn't make much sense if it was working with older versions of Liquibase.

So let's get the obvious out of the way :-)

JanCizmar commented 3 years ago

Hello, after updating to version 4.2.2 of Liquibase core and hibernate5, the problem disappeared. Thanks a lot for your time. :)