Jahia 8
NullPointerException after migrating a module to Jahia 8
Question
After migrating a module to Jahia 8. A NullPointerException is being thrown when accessing some functions. An example stacktrace is as below:
2020-06-15 09:33:50,646: ERROR [RenderChain] - Error while rendering the resource: Resource{node=/modules/testModule/2.0/templates/server-settings-base/configurations/test-configuration/pagecontent/test-configuration, primaryNodeTypeName=‘tmix:testConfiguration', templateType='html', template='default', configuration='module'} java.lang.NullPointerException at org.jahia.services.render.webflow.WebflowDispatcherScript.execute(WebflowDispatcherScript.java:182) at org.jahia.services.render.filter.TemplateScriptFilter.prepare(TemplateScriptFilter.java:139) at org.jahia.services.render.filter.RenderChain.doFilter(RenderChain.java:167) at org.jahia.services.render.RenderService.render(RenderService.java:255) at org.jahia.taglibs.template.include.ModuleTag.render(ModuleTag.java:592) at org.jahia.taglibs.template.include.ModuleTag.doEndTag(ModuleTag.java:287) at org.apache.jsp.modules.default_.jmix_005flist.html.list_jsp._jspx_meth_template_005fmodule_005f0(list_jsp.java:597). ...
Cause
The issue was caused by having a dependency on Spring frameworks (e.g. Webflow) which needs to be explicitly declared in the modules POM.xml files. For more information kindly consult Jahia migration guide below:
Solution
The solution to this is to make sure that Spring dependencies are correctly configured in POM.xml as mentioned in the migration guide. Below is a an example configuration:
...
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jahia.modules</groupId>
<artifactId>jahia-modules</artifactId>
<version>8.0.0.0</version>
</parent>
<groupId>org.testModule.modules</groupId>
<artifactId>testModule</artifactId>
<version>2.0</version>
<packaging>bundle</packaging>
<name>testModule</name>
<description>This is test module to be compatible with Jahia 8</description>
<properties>
<jahia-depends>default,bootstrap3-core,serverSettings</jahia-depends>
<require-capability>osgi.extender;filter:="(osgi.extender=org.jahia.bundles.blueprint.extender.config)"</require-capability>
</properties>
<dependencies>
...
</dependencies>
...