SpringLiquibase: includeAll within jar causes NullPointerException
Description
This issue is related to CORE-1986. If an includeAll is used inside a jar to include other files from the jar a NullPointerException occurs.
The attached files include a jar with the following structure:
changelogs
|-- test-changeLog1.xml // includesAll from "test" directory
\-- test
\-- test-changeLog2.xml
The file test-changeLog1.xml includes all files from the "test" directory also inside the jar, causing the following exception:
...
Caused by: liquibase.exception.SetupException: liquibase.exception.SetupException
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:247)
at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:211)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
... 47 more
Caused by: liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:27)
at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:353)
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:245)
... 49 more
Caused by: liquibase.exception.SetupException
at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:331)
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:261)
at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:211)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
... 51 more
Caused by: java.lang.NullPointerException
at java.util.AbstractCollection.addAll(AbstractCollection.java:303)
at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.list(SpringLiquibase.java:91)
at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:313)
... 54 more
The path passed to super.list() in SpringLiquibase$SpringResourceOpener has the form
Thank you for the quick reply, but after testing in 3.3.1 I got a SetupException and opened CORE-2166. It includes a test project which reproduces the problem.
This issue is related to CORE-1986. If an includeAll is used inside a jar to include other files from the jar a NullPointerException occurs.
The attached files include a jar with the following structure:
changelogs |-- test-changeLog1.xml // includesAll from "test" directory \-- test \-- test-changeLog2.xml
The file test-changeLog1.xml includes all files from the "test" directory also inside the jar, causing the following exception:
... Caused by: liquibase.exception.SetupException: liquibase.exception.SetupException at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:247) at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:211) at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25) ... 47 more Caused by: liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:27) at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:353) at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:245) ... 49 more Caused by: liquibase.exception.SetupException at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:331) at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:261) at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:211) at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25) ... 51 more Caused by: java.lang.NullPointerException at java.util.AbstractCollection.addAll(AbstractCollection.java:303) at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.list(SpringLiquibase.java:91) at liquibase.changelog.DatabaseChangeLog.includeAll(DatabaseChangeLog.java:313) ... 54 more
The path passed to super.list() in SpringLiquibase$SpringResourceOpener has the form
jar:file:/home/user/Desktop/test/test-liquibase.jar!/changelogs/test/
This causes list() to return null because classLoader.getResource(path) returns null.
As a workaround the code from the first comment on https://liquibase.jira.com/browse/CORE-1986#icft=CORE-1986 works.