Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on running liquibase:diff when using >= Liquibase-core 3.6 #195

Open
ghost opened this issue Mar 29, 2019 · 22 comments
Open

NPE on running liquibase:diff when using >= Liquibase-core 3.6 #195

ghost opened this issue Mar 29, 2019 · 22 comments

Comments

@ghost
Copy link

ghost commented Mar 29, 2019

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.

[INFO] Executing on Database: jdbc:jtds:sqlserver://localhost/MyDatabase;instance=sqlexpress
[WARNING] Unknown database: Hibernate
[INFO] Performing Diff on database sa @ jdbc:jtds:sqlserver://localhost/MyDatabase;instance=sqlexpress (Default Schema: dbo)
[INFO] Error getting default schema
java.lang.NullPointerException
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:452)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:93)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:135)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:146)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:154)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:169)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:164)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:327)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:292)
at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:151)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:184)
at liquibase.command.core.DiffCommand.createReferenceSnapshot(DiffCommand.java:221)
at liquibase.command.core.DiffCommand.createDiffResult(DiffCommand.java:143)
at liquibase.command.core.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:237)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:212)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:177)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:366)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:136)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Those are the contents of my liquibase.properties:

changeLogFile=src/main/migrations/db-changelog.xml
outputChangeLogFile=src/main/migrations/db-changelog-generated.xml
diffChangeLogFile=src/main/migrations/diff.xml

Connection

driver=net.sourceforge.jtds.jdbc.Driver
dialect=org.hibernate.dialect.SQLServer2005Dialect
defaultSchemaName=dbo
url=jdbc:jtds:sqlserver://localhost/MyDatabase;instance=sqlexpress
username=sa
password=topsecredPassword

referenceUrl=hibernate:spring:com.mybeans?dialect=org.hibernate.dialect.SQLServer2005Dialect
referenceUsername=root
referencePassword=password
referenceDefaultSchema=hibernate

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

@ghost
Copy link
Author

ghost commented Mar 30, 2019

Hibernate4 btw!

@madas92
Copy link

madas92 commented Apr 6, 2019

Hy, can you add your pom.xml file?
I tryed with 3.5.5 and it`s not working.
Thanks!

@ghost
Copy link
Author

ghost commented Apr 6, 2019

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!

@madas92
Copy link

madas92 commented Apr 6, 2019

I use hibernate4 version. here is a part of my pom:


org.liquibase
liquibase-maven-plugin
3.6.3

src/main/resources/liquibase/liquibase-changeLog.xml

src/main/resources/liquibase/changelog/${maven.build.timestamp}_changelog.xml

hibernate:spring:com.example?dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
&
hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

public
org.postgresql.Driver
jdbc:postgresql://localhost:5432/postgres
user
pass
debug
true



update-profile
process-resources

update



diff-profile
process-test-resources

diff





org.liquibase.ext
liquibase-hibernate4
3.5


I run mvn process-test-resources

and I get: : Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException

@ghost
Copy link
Author

ghost commented Apr 6, 2019

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 ;)

@madas92
Copy link

madas92 commented Apr 6, 2019

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.

@ghost
Copy link
Author

ghost commented Apr 6, 2019

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.

@madas92
Copy link

madas92 commented Apr 6, 2019

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:

@ghost
Copy link
Author

ghost commented Apr 8, 2019

Maybe I can help you if you post your POM and liquibase properties.

@myin142
Copy link

myin142 commented Aug 13, 2019

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.

@Migsi
Copy link

Migsi commented Sep 18, 2019

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

@myin142
Copy link

myin142 commented Sep 19, 2019

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.

<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>

@DanielFran
Copy link
Contributor

DanielFran commented Dec 20, 2019

Anyone able to confirm if using liquibase 3.8.3 and spring-boot 2.2 issue is fixed?

@umbertooo
Copy link

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

@pieterdegraeuwe
Copy link

pieterdegraeuwe commented Jul 31, 2021

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

@otskarli
Copy link

otskarli commented Feb 23, 2022

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

@SpectralAngel
Copy link

SpectralAngel commented Jun 24, 2022

@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

@bohdan-shulha
Copy link

@SpectralAngel , thank you. Helped me as well.

@taichouvik
Copy link

taichouvik commented Sep 2, 2023

@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>

@pvncoder
Copy link

@taichouvik thanks, man! This worked for me in the Maven project as well.

@Giddu
Copy link

Giddu commented Mar 14, 2024

@SpectralAngel , thanks a lot. I'm using gradle with kotlin so adding liquibaseRuntime("org.springframework.boot:spring-boot-starter-data-jpa") worked for me.

@filipelautert
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests