Open ghost opened 5 years ago
Hibernate4 btw!
Hy, can you add your pom.xml file? I tryed with 3.5.5 and it`s not working. Thanks!
What i did to make it work was adding some dependencies directly to the plugin configuration: https://stackoverflow.com/a/46414892
I looked further into my issue and noticed that the pull request for the update to liquibase 3.6 on master was not backported to the hibernate 4 branch. Did this happen on purpose? Is the hibernate 4-Version of this plugin EOL?
Thanks in advance!
I use hibernate4 version. here is a part of my pom:
Yes, it is currently NOT working with liquibase-core 3.6 or higher. It works with liquibase-core 3.5.5.
That's what im trying to point out with my issue ;)
I have used the pom file posted by you and I get: Execution update-profile of goal org.liquibase:liquibase-maven-plugin:3.6.3:update failed: An API incompatibility was encountered while execut ing org.liquibase:liquibase-maven-plugin:3.6.3:update: java.lang.NoSuchMethodError: liquibase.integration.commandline.CommandLineUtils.getBanner()Ljava/lang/String; [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.liquibase:liquibase-maven-plugin:3.6.3 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] ----------------------------------------------------- [ERROR] [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
Try setting the liquibase-maven-plugin version to 3.5.5 aswell. And use the hibernate/spring/... versions that you use in the rest of your project.
I set to 3.5.5, also to 3.5.0 and any result. Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:diff (default-cli) on project rest-api: Error setting up or running Liquibase: liquibase.exception.DatabaseException:
Maybe I can help you if you post your POM and liquibase properties.
I finally solved all those error I am getting with liquibase generation. You pointed me to the right direction, that there was a problem with the versions.
In the end I used: Liquibase-Hibernate5 3.7 Liquibase 3.6.0 Liquibase-Maven 3.6.0 Hibernate 5.1.17.Final
Liquibase Maven Dependencies: Liquibase-Hibernate5 3.7 javax.validation validation-api 2.0.1.Final postgresql 42.2.6
I just looked at the latest liquibase post about hibernate and saw that version 3.7 supports liquibase 3.6. Some of them can obviously be changed like postgresql or maybe hibernate version. But I am never touching anything with these versions anymore...
Edit: And apparently you cannot use a higher java version than 8. Otherwise it fails because of the JAXB API.
I commented already in the other issue, referencing this, but I'd like to provide my testing pom.xml for further elaboration:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.17.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.6</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.0</version>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.6</version>
</dependency>
</dependencies>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
As already explained in the other thread, I keep getting an NPE while getting the schema
I got past the NPE but there seems to be another error after that. There is also an open issue for it #170
Here is my pom.xml. The important parts are the spring boot dependencies inside liquibase hibernate. <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/>
</parent>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<liquibase.hibernate>3.7</liquibase.hibernate>
<liquibase.version>3.6.0</liquibase.version>
<liquibase.maven>3.6.0</liquibase.maven>
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<hibernate-core.version>5.4.5.Final</hibernate-core.version>
<h2.version>1.4.199</h2.version>
<javax.validation>2.0.1.Final</javax.validation>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.maven}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase.hibernate}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.maven}</version>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase.hibernate}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax.validation}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<configuration>
<changeLogFile>src/main/resources/changelog.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/diff-changelog-${maven.build.timestamp}.xml</diffChangeLogFile>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:mem:test</url>
<referenceUrl>hibernate:spring:com:test?dialect=org.hibernate.dialect.H2Dialect</referenceUrl>
<referenceDriver>liquibase.ext.hibernate.database.connection.HibernateDriver</referenceDriver>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Anyone able to confirm if using liquibase 3.8.3 and spring-boot 2.2 issue is fixed?
I came across this issue using
liquibase-core:4.4.1
liquibase-maven-plugin:4.4.1
liquibase-hibernate5:4.4.1
and got the stacktrace
[INFO] Performing Diff on database postgres @ jdbc:postgresql://localhost:5432/mydatabase (Default Schema: public)
[INFO] Error getting default schema
java.lang.NullPointerException
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement (JdbcExecutor.java:494)
at liquibase.executor.jvm.JdbcExecutor.execute (JdbcExecutor.java:118)
at liquibase.executor.jvm.JdbcExecutor.query (JdbcExecutor.java:160)
at liquibase.executor.jvm.JdbcExecutor.query (JdbcExecutor.java:171)
at liquibase.executor.jvm.JdbcExecutor.queryForObject (JdbcExecutor.java:179)
at liquibase.executor.jvm.JdbcExecutor.queryForObject (JdbcExecutor.java:194)
at liquibase.executor.jvm.JdbcExecutor.queryForObject (JdbcExecutor.java:189)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName (AbstractJdbcDatabase.java:365)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName (AbstractJdbcDatabase.java:325)
As hTnevS mentioned, adding dependencies to worked for me.
This plugin configuration inside pom.xml
did the trick:
...
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.4.1</version>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.3.8</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>
The referenced Spring dependencies match the corresponding versions in Spring Boot 2.5.2
same here, but when running from the commandline (liquibase cli)
Unexpected error running Liquibase: java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.next()" because "catalogs" is null
Liquibase Version: 4.4.2 Liquibase Community 4.4.2 by Datical
liquibase.properties:
driver=org.postgresql.Driver changeLogFile=src/main/resources/config/liquibase/master.xml url=jdbc:postgresql://localhost:5433/GEODesk username= password= referenceUrl=hibernate:spring:com.geodesk.?dialect=org.hibernate.dialect.PostgreSQL9Dialect
diffChangeLogFile=com/mypackage/dbchangelog/diff-changelog.xml
defaultCatalogName=GEODesk classpath=F:/projects/geo-desk/services/server/out/production/classes;F:/projects/geo-desk/services/server/src/main/resources;C:/Users/Pieter/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/42.2.20/36cc2142f46e8f4b77ffc1840ada1ba33d96324f/postgresql-42.2.20.jar;C:/Users/Pieter/.gradle/caches/modules-2/files-2.1/org.liquibase.ext/liquibase-hibernate5/4.2.2/6cbf0799af02f47a6a3195a46b36960d11454db4/liquibase-hibernate5-4.2.2.jar;C:/Users/Pieter/.gradle/caches/modules-2/files-2.1/org.hibernate/hibernate-core/5.5.3.Final/a511745f0d2c73f712ad128c356a5a5bd0137707/hibernate-core-5.5.3.Final.jar
This seems to be not fixed, or do i have wrong configuration, what am I doing wrong here.
Edit: added plugins also
plugins {
id("org.springframework.boot") version "3.0.0-SNAPSHOT"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.liquibase.gradle") version "2.1.1"
kotlin("jvm") version "1.6.0"
kotlin("plugin.spring") version "1.6.0"
kotlin("plugin.jpa") version "1.6.0"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
liquibaseRuntime("org.postgresql:postgresql:42.2.24")
liquibaseRuntime("org.liquibase:liquibase-core:4.7.1")
liquibaseRuntime("org.liquibase.ext:liquibase-hibernate5:4.7.1")
liquibaseRuntime("org.liquibase:liquibase-groovy-dsl:3.0.0")
liquibaseRuntime("info.picocli:picocli:4.6.1")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
liquibase {
activities.register("main") {
this.arguments = mapOf(
"changeLogFile" to "src/main/resources/db/changelog/db.changelog-master.sql",
"url" to prop.getProperty("spring.datasource.url"),
"username" to prop.getProperty("spring.datasource.username"),
"password" to prop.getProperty("spring.datasource.password"),
"driver" to "org.postgresql.Driver",
"referenceUrl" to "hibernate:spring:com.helmes.pjm.testing.entity?dialect=org.hibernate.dialect.PostgreSQL92Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"
)
}
runList = "main"
}
}
Error
Starting Liquibase at 12:46:15 (version 4.7.1 #1239 built at 2022-01-20 20:31+0000) Liquibase Version: 4.7.1 Liquibase Community 4.7.1 by Liquibase
Diff Results:
Unexpected error running Liquibase: java.lang.NullPointerException: Cannot invoke "java.sql.ResultSet.next()" because "catalogs" is null
For more information, please use the --log-level flag
Task :diff FAILED
@otskarli I fixed the same error by adding
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
The part of the Dialects needs to be in the classpath, I think it could be down to more specific libraries, but it worked that way with my project
@SpectralAngel , thank you. Helped me as well.
@SpectralAngel, thanks worked like this (for maven)
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.23.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate6</artifactId>
<version>4.23.1</version>
</dependency>
</dependencies>
</plugin>
@taichouvik thanks, man! This worked for me in the Maven project as well.
@SpectralAngel , thanks a lot. I'm using gradle with kotlin so adding liquibaseRuntime("org.springframework.boot:spring-boot-starter-data-jpa")
worked for me.
So in short, using an url that points to spring objects requires spring-data libraries to be included as dependencies too. What could be done to improve the extensions is instead of throwing a null pointer print out a message explaining what could be done to fix the issue.
I get a NullPointerException when executing mvn liquibase:diff. This happens only when using liquibase-core 3.6.0 or above. Tested it with liquibase-core 3.5.5, that worked with my configuration.
Those are the contents of my liquibase.properties:
I tried several configurations but as i pointed out, liquibase:diff worked without trouble on version 3.5.5 and below.
┆Issue is synchronized with this Jira Bug by Unito