liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

org.springframework.boot:2.6.2 causes diff/diffChangeLog task to raise NoSuchMethodError #99

Closed robertu-hilarion5 closed 2 years ago

robertu-hilarion5 commented 2 years ago

Hi, I upgraded my application to Spring Boot 2.6.2. After that diff and diffChangeLog gradle tasks do not work anymore. With Spring Boot 2.6.1 it's working fine.

Here is the stacktrace:

[2022-01-04 09:59:57] SEVERE [liquibase.integration] Unerwarteter Fehler bei der Ausf�hrung von Liquibase: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'
java.lang.NoSuchMethodError: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'
    at liquibase.ext.hibernate.snapshot.SequenceSnapshotGenerator.addTo(SequenceSnapshotGenerator.java:63)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:82)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:314)
    at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:105)
    at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:58)
    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.InternalDiffCommandStep.createReferenceSnapshot(InternalDiffCommandStep.java:188)
    at liquibase.command.core.InternalDiffCommandStep.createDiffResult(InternalDiffCommandStep.java:98)
    at liquibase.command.core.InternalDiffChangelogCommandStep.run(InternalDiffChangelogCommandStep.java:49)
    at liquibase.command.CommandScope.execute(CommandScope.java:147)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:205)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1607)
    at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:402)
    at liquibase.Scope.lambda$child$0(Scope.java:177)
    at liquibase.Scope.child(Scope.java:186)
    at liquibase.Scope.child(Scope.java:176)
    at liquibase.Scope.child(Scope.java:155)
    at liquibase.integration.commandline.Main$1.run(Main.java:401)
    at liquibase.integration.commandline.Main$1.run(Main.java:225)
    at liquibase.Scope.child(Scope.java:186)
    at liquibase.Scope.child(Scope.java:162)
    at liquibase.integration.commandline.Main.run(Main.java:225)
    at liquibase.integration.commandline.Main.main(Main.java:168)

> Task :diffChangeLog FAILED

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

Attached you can find the example project created using start.spring.io.

Gradle Version: 7.3.2 Java: 17.0.1 liquibasetest.zip

Here is the yml file that will startup a postgres docker container:

version: '2'
services:
    liquibasetestservice:
        container_name: liquibase_test
        image: postgres:13
        environment:
            - POSTGRES_USER=springboot
            - POSTGRES_PASSWORD=mypassword
            - POSTGRES_DB=testdb
        ports:
            - 5432:5432
stevesaliman commented 2 years ago

Thank you for the complete test case. It makes it much easier to troubleshoot issues :-)

This is a known issue with the liquibase-hibernate5 extension.

Hibernate changed something in their API for version 5.6.2 that is not backwards compatible with the liquibase-hibernate5 extension. This is something the liquibase-hibernate5 developers. will need to fix.

You see this problem when you upgrade to Spring Boot 2.6.2 because that changes the Hibernate version from Hibernate 5.6.1. to 5.6.3.

It is also worth mentioning that start.spring.io doesn't always use the latest versions of things. It brings in version 4.4.3 of the liquibase-hibernate5 extension, and the latest release is 4.6.2. When they fix the liquibase-hibernate5 extension, you'll need to update your build.gradle file accordingly.