NullPointerException when generating changelog liquibase 3.0.3

Hi guys,


Can you help me with the exception below that I’m getting with liquibase 3.0.3


SEVERE 9/2/13 2:44 PM:liquibase: java.lang.NullPointerException

liquibase.exception.DatabaseException: java.lang.NullPointerException

        at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:178)

        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59)

        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:42)

        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)

        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:42)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:75)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:157)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)

        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:157)

        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)

        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)

        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:128)

        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:121)

        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:163)

        at liquibase.integration.commandline.Main.doMigration(Main.java:783)

        at liquibase.integration.commandline.Main.main(Main.java:138)

Caused by: java.lang.NullPointerException

        at liquibase.diff.compare.core.ForeignKeyComparator.isSameObject(ForeignKeyComparator.java:41)

        at liquibase.diff.compare.DatabaseObjectComparatorChain.isSameObject(DatabaseObjectComparatorChain.java:39)

        at liquibase.diff.compare.DatabaseObjectComparatorFactory.isSameObject(DatabaseObjectComparatorFactory.java:92)

        at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:164)

        … 48 more



Thanks

BTW, I’m using Oracle 11g

It appears to be the same problem as http://forum.liquibase.org/topic/possible-bug-in-foreignkeycomparator-issameobject-introduced-by-3-0-3-release  There should be a new 3.0.4 version that fixes it out later this week.


Nathan

Cool! For me, it was working with 3.0.2 with the same database

Here’s the diff between 3.0.2 and 3.0.3 for that class


  1. git diff liquibase-parent-3.0.2 liquibase-parent-3.0.3 liquibase-core/src/main/java/liquibase/snapshot/jvm/ForeignKeySnapshotGenerator.java
  2. diff --git a/liquibase-core/src/main/java/liquibase/snapshot/jvm/ForeignKeySnapshotGenerator.java b/liquibase-core/src/main/java/liquibase/snapshot/jvm/ForeignKeySnapshotGenerator.
  3. index b8a87e9..8f9335f 100644
  4. --- a/liquibase-core/src/main/java/liquibase/snapshot/jvm/ForeignKeySnapshotGenerator.java
  5. +++ b/liquibase-core/src/main/java/liquibase/snapshot/jvm/ForeignKeySnapshotGenerator.java
  6. @@ -165,9 +165,11 @@ public class ForeignKeySnapshotGenerator extends JdbcSnapshotGenerator {
  7.                      continue;
  8.                  }

  9. -                Index exampleIndex = new Index().setTable(foreignKey.getForeignKeyTable());
  10. -                exampleIndex.getColumns().addAll(Arrays.asList(foreignKey.getForeignKeyColumns().split("\\s*,\\s*")));
  11. -                foreignKey.setBackingIndex(exampleIndex);
  12. +                if (database.createsIndexesForForeignKeys()) {
  13. +                    Index exampleIndex = new Index().setTable(foreignKey.getForeignKeyTable());
  14. +                    exampleIndex.getColumns().addAll(Arrays.asList(foreignKey.getForeignKeyColumns().split("\\s*,\\s*")));
  15. +                    foreignKey.setBackingIndex(exampleIndex);
  16. +                }

  17.                  return foreignKey;
  18.              }

3.0.4 is now out that should fix this problem. Let me know if it works better for you.


Nathan