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

NullPointerException when using liquibase-hibernate with Liquibase Maven Plugin #52

Closed
mdettlaff opened this issue Jun 13, 2014 · 3 comments

Comments

@mdettlaff
Copy link

Hi,

Unfortunately it looks like liquibase-hibernate4 version 3.4 does not work with Liquibase Maven Plugin. I created a very simple project to reproduce the issue: https://github.com/mdettlaff-mb/LiquibaseHibernateTest

When I run:

$ mvn -e liquibase:diff

I get this error:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.0:diff (default-cli) on project liquibase-hibernate-test: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.0:diff (default-cli) on project liquibase-hibernate-test: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:371)
        at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:74)
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:58)
        at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:159)
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:367)
        ... 22 more
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:72)
        ... 25 more
Caused by: java.lang.NullPointerException
        at liquibase.diff.core.StandardDiffGenerator.compareObjectType(StandardDiffGenerator.java:73)
        at liquibase.diff.core.StandardDiffGenerator.compare(StandardDiffGenerator.java:49)
        at liquibase.diff.DiffGeneratorFactory.compare(DiffGeneratorFactory.java:100)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:143)
        at liquibase.command.DiffCommand.run(DiffCommand.java:132)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 26 more

When I change the Liquibase Maven Plugin version from 3.2.0 to 3.1.1 I get a different error, but it seems that this version is no longer supported, so it's probably normal.

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (default-cli) on project liquibase-hibernate-test: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:3.1.1:diff failed: An API incompatibility was encountered while executing org.liquibase:liquibase-maven-plugin:3.1.1:diff: java.lang.NoSuchMethodError: liquibase.structure.core.Schema.setDefault(Ljava/lang/Boolean;)Lliquibase/structure/core/Schema;

Running with Liquibase 3.2.0 from the command line instead of Maven plugin works as expected.

$ liquibase --url "jdbc:h2:~/tmp/sampledb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE" --username sa --password sa --referenceUrl="hibernate:ejb3:samplepu?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy" --changeLogFile="src/main/resources/db-changelog.xml" --classpath="target/classes" diffChangeLog
@vrudikov
Copy link

I've got the same exception

@vrudikov
Copy link

I've tried this code in debugger instead of null value in doDiffToChangeLog call

new CompareControl.SchemaComparison[]{new CompareControl.SchemaComparison(CatalogAndSchema.DEFAULT, CatalogAndSchema.DEFAULT)}
public static void doDiffToChangeLog(String changeLogFile,
                                         Database referenceDatabase,
                                         Database targetDatabase,
                                         DiffOutputControl diffOutputControl,
                                         String snapshotTypes)
            throws LiquibaseException, IOException, ParserConfigurationException {
        doDiffToChangeLog(changeLogFile, referenceDatabase, targetDatabase, diffOutputControl, snapshotTypes, null);
    }

and now i'm getting BUILD SUCCESS and generated schema file
i think this minor fix must be presented in liquibase-core(CommandLineUtils.java) 3.2.1

@mdettlaff
Copy link
Author

I'm closing this issue since this appears to be a bug in liquibase-core, and there is now an issue for it in Liquibase JIRA:
https://liquibase.jira.com/browse/CORE-1936

Let's continue the discussion there.

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

2 participants