I was running the generateChangeLog command and I ran into the following error:
INFO 6/14/11 10:15 AM:liquibase: c:\temp\test.diff exists, appending
Liquibase Update Failed: Unknown Reason
SEVERE 6/14/11 10:15 AM:liquibase: Unknown Reason
java.lang.NullPointerException
at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:507)
at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:426)
at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:406)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:151)
at liquibase.integration.commandline.Main.doMigration(Main.java:624)
at liquibase.integration.commandline.Main.main(Main.java:116)
I checked out the code and ran it through the debugger. I found that the serializer is determined from the file extension of the --changeLogFile parameter. As I walked through the code in the debugger, there are two serializers set up: xml and txt. If you provide a different extension for the output file (as I did), you’ll get a NPE as above because the code on line 405 in liquibase.diff.DiffResult will return null:
ChangeLogSerializer changeLogSerializer = serializerFactory.getSerializer(changeLogFile);
I would suggest doing the one of the following:
-
at the very least, check after line 405 and make sure the serializer isn’t null – throw an exception with a meaningful message if it is – even better (because sooner), as part of the validation of the command-line arguments, make sure the given extension is valid; or
-
perhaps change the SerializerFactory to default to either the xml or txt serializer if one can’t be found for the given extension
I’d be happy to submit a patch if it would help – let me know!
Thanks for the great tool!
Andrew