[ https://issues.apache.org/jira/browse/VELOCITY-367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chris Wells updated VELOCITY-367: --------------------------------- Reporter: Henning Schmiedehausen (was: Henning Schmiedehausen) > Anakia throws NullPointerException if run under Maven with Custom Contexts > -------------------------------------------------------------------------- > > Key: VELOCITY-367 > URL: https://issues.apache.org/jira/browse/VELOCITY-367 > Project: Velocity > Issue Type: Bug > Components: Anakia > Affects Versions: 1.5 > Environment: Operating System: Linux > Platform: All > Reporter: Henning Schmiedehausen > Priority: Major > Attachments: ASF.LICENSE.NOT.GRANTED--anakia.patch > > > The AnakiaTask has the feature to use a custom context object. This is tested > in > the AnakiaTestCase. However, when running this test (and the AnakiaTask) under > Maven, it fails with a NullPointerException. The reason is that maven uses a > different sequence to initialize the AnakiaTask and Context objects and set > their properties. When running under ant, the setFile() method in the Context > object is called after setBaseDir() in the AnakiaTask, which allows setFile() > to > resolve the baseDir member. When running under maven, setBasedir() is called > after the Context object has been initialized thus using a null baseDir > element > when creating the contextFile element in Context. > When using an element outside the current working directory, this leads to > subContext.getContextDocument() returning null in line 378, thus resulting in > a > NullPointerException. > The attached patch adds checks for this condition and throws a BuildExeption. > It > also defers the creation of the contextDoc member of the context until it is > actually referenced. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org