[MAGNOLIA-5781] NPE when using BootstrapConditionally simplest constructor Created: 22/May/14 Updated: 09/Dec/14 Resolved: 12/Nov/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | core, updatemechanism |
| Affects Version/s: | 5.2.3 |
| Fix Version/s: | 5.3.6 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Moritz Siuts | Assignee: | Daniel Lipp |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | maintenance, quickwin | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
When using a the BootstrapConditionally Task (in Magnolia 5.2.3) with this constructor public BootstrapConditionally(String taskName, String resourceToBootstrap) one gets a NPE when the task ist excuted (see below). public BootstrapConditionally(String taskName, String taskDescription, String repositoryName, String pathToCheck, String resourceToBootstrap, Task ifNodeExists) but I think because the javadoc of the class says "A Task which bootstraps if the node targeted by the bootstrap file does not exist." it should better delegate to public BootstrapConditionally(String taskName, String taskDescription, String resourceToBootstrap) Workaround is to use this constructor directly.
ERROR info.magnolia.module.InstallContextImpl - > Error while installing or updating XXXX module. Task 'YYYYY' failed. (NullPointerException: )
java.lang.NullPointerException
at info.magnolia.importexport.BootstrapUtil.getFilenameFromResource(BootstrapUtil.java:182)
at info.magnolia.importexport.BootstrapUtil.bootstrap(BootstrapUtil.java:75)
at info.magnolia.module.delta.BootstrapResourcesTask.execute(BootstrapResourcesTask.java:72)
at info.magnolia.module.delta.ConditionalDelegateTask.execute(ConditionalDelegateTask.java:61)
at info.magnolia.module.delta.ConditionalDelegateTask.execute(ConditionalDelegateTask.java:61)
at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:509)
at info.magnolia.module.ModuleManagerImpl$3.doExec(ModuleManagerImpl.java:389)
at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:414)
at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:411)
at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:385)
at info.magnolia.module.ModuleManagerImpl.executeStartupTasks(ModuleManagerImpl.java:382)
at info.magnolia.module.ModuleManagerImpl.startModules(ModuleManagerImpl.java:297)
at info.magnolia.module.ui.ModuleManagerNullUI.onStartup(ModuleManagerNullUI.java:74)
at info.magnolia.cms.beans.config.ConfigLoader.load(ConfigLoader.java:149)
at info.magnolia.init.MagnoliaServletContextListener$1.doExec(MagnoliaServletContextListener.java:248)
at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:414)
at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:411)
at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:385)
at info.magnolia.init.MagnoliaServletContextListener.startServer(MagnoliaServletContextListener.java:245)
at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:171)
at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:125)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2014-05-21 13:20:25,369 [localhost-startStop-1] ERROR info.magnolia.cms.beans.config.ConfigLoader - An unspecified error occurred during initialization: null
java.lang.NullPointerException
at info.magnolia.importexport.BootstrapUtil.getFilenameFromResource(BootstrapUtil.java:182)
at info.magnolia.importexport.BootstrapUtil.bootstrap(BootstrapUtil.java:75)
at info.magnolia.module.delta.BootstrapResourcesTask.execute(BootstrapResourcesTask.java:72)
at info.magnolia.module.delta.ConditionalDelegateTask.execute(ConditionalDelegateTask.java:61)
at info.magnolia.module.delta.ConditionalDelegateTask.execute(ConditionalDelegateTask.java:61)
at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:509)
|
| Comments |
| Comment by Daniel Lipp [ 12/Nov/14 ] |
|
According to my investigations the NPE doesn't happen because the task to be executed otherwise == null. This is a valid condition and is properly handled in the ConditionDelegateTask#execute(InstallContext) implementation. The only condition one could get an NPE with the attached stack trace is when calling that constructor with the resourceToBootstrap == null. Feel free to re-open if you think we still should do something about it. Anyways I added the missing javadoc to that constructor. |
| Comment by Jan Haderka [ 12/Nov/14 ] |
|
Imo, you should check for existence of the resource in bootstrap task and throw NPE with the meaningful message (file/path xyz you tried to bootstrap doesn't exist) instead of relying on ability of the user to interpret stacktrace meaning and trace down incorrect path. |
| Comment by Moritz Siuts [ 12/Nov/14 ] |
|
I actually did not find the commit with the new javadoc, but my problem was that: new BootstrapConditionally("PublishDateCommand", CONFIG_RESOURCE_DIR + "config.modules.workflow.commands.workflow.activate.publishingDate.xml");
throws the NPE and new BootstrapConditionally("PublishDateCommand", "a description", CONFIG_RESOURCE_DIR + "config.modules.workflow.commands.workflow.activate.publishingDate.xml"),
does not. |
| Comment by Daniel Lipp [ 12/Nov/14 ] |
|
re Jan: yup we should avoid meaningless NPE -> non-existing resources are already covered but I'll add a check for null-resourceNames and throw a IAE with a nice message... |
| Comment by Daniel Lipp [ 12/Nov/14 ] |
|
ta Moritz for the clarification (that was fast reaction |