newsletter System Administrator Jahia 7.3 Legacy

Null Pointer Exception on Newsletter module


The newsletter module produces a Null Pointer Exception when you create a newsletter. How we can fix this Null Pointer Exception? Error while rendering the resource: Resource{node=/modules/newsletter/3.1.3/templates/site-settings-base/newsletterManager/pagecontent/newsletter-manager, primaryNodeTypeName='jnt:siteSettingsManageNewsletters', templateType='html', template='default', configuration='module'} org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@2c6b09b1 targetAction = [EvaluateAction@e1940e expression = flowHandler.getNewsletterTemplates(flowRequestContext), resultExpression = requestScope.newsletterTemplates], attributes = map[[empty]]] in state 'formIssue' of flow 'jnt_siteSettingsManageNewsletters/html/siteSettingsManageNewsletters.flow' -- action execution attributes were 'map[[empty]]'


Caused by: java.lang.NullPointerException
 at org.jahia.modules.newsletter.sitesettings.ManageNewsletterFlowHandler.getNewsletterTemplates(


Usually, the problem is a missing module on the Web Project. To identify guilty module on the website, please execute the following script (change in the first line "digitall" to your website key):

        String siteKey = "digitall";
        JCRSessionWrapper systemSession = JCRSessionFactory.getInstance().getCurrentSystemSession("default", session.getLocale(), null);
        TemplatePackageRegistry templatePackageRegistry = org.jahia.registries.ServicesRegistry.getInstance().getJahiaTemplateManagerService().getTemplatePackageRegistry();
        JCRSiteNode siteNode = org.jahia.registries.ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(siteKey, systemSession);
        List<String> installedModules = siteNode.getAllInstalledModules();
        for (String installedModule : installedModules) {
                 JahiaTemplatesPackage module = templatePackageRegistry.getRegisteredModules().get(installedModule);
       "InstalledModule: " + installedModule + " Module: " + module);

The script can be executed in the jcrConsole in Jahia Tools. The script should produce some log outputs: first, the module name, second, the module itself (usually it should be the name too). In case the second part is "null", the solution would be to reinstall the missing module or update the Web Project and remove the module from the dependencies.

If the script doesn't show any guilty modules, you would have to restart the server to reinitialize the templatePackageRegistry which happens at startup.