Legacy Knowledge Base
Published Jul. 2, 2025

Error executing FreeMarker template with #null when rendering web content

Written By

Sergio Alonso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • When trying to render a web content we get the following error in Liferay DXP log:
    2021-02-12 11:41:48.911 ERROR [http-nio-8080-exec-9][runtime:59] Error executing FreeMarker template
    FreeMarker template error:
    The following has evaluated to null or missing:
    ==> webContentData.title [in template "20101#20128#null" at line 14, column 11]

    ----
    Tip: It's the step after the last dot that caused this error, not those before it.
    ----
    Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
    ----

    ----
    FTL stack trace ("~" means nesting-related):
    - Failed at: ${webContentData.title} [in template "20101#20128#null" at line 14, column 9]
    ----

    Java stack trace (for programmers):
    ----
    freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
    at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
    at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:479)
    at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401)
    at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:370)
    at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100)
    at freemarker.core.DollarVariable.accept(DollarVariable.java:63)
    at freemarker.core.Environment.visit(Environment.java:331)
    at freemarker.core.Environment.visit(Environment.java:337)
    at freemarker.core.Environment.process(Environment.java:310)
    at freemarker.template.Template.process(Template.java:383)
    at com.liferay.portal.template.freemarker.internal.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:154)
    at com.liferay.portal.template.BaseTemplate.processTemplate(BaseTemplate.java:163)
    at com.liferay.journal.internal.transformer.JournalTransformer.doTransform(JournalTransformer.java:367)
    at com.liferay.journal.internal.transformer.JournalTransformer.transform(JournalTransformer.java:103)
    at com.liferay.journal.internal.util.JournalUtil.transform(JournalUtil.java:424)
    at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:7962)
    at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2516)
    ...
    ...
    ...
  • The web content has a structure but no associated template.

Environment

  • Liferay DXP 7.2
  • Liferay DXP 7.3

Resolution

  • This issue happens when the structure defines a field of type 'web content' (internally denoted as 'ddm-journal-article') and this field has no assigned value in the web content based on the structure.
  • In this case, Liferay processes the 'ddm-journal-article' field using with it the default FreeMarker template journal-article.ftl. This template assumes that the 'ddm-journal-article' field provides certain values such as the web content title.
  • However, since the field has no value the template gets a null value and this causes a parsing error from the FreeMarker template.
  • There are two options to solve the issue:
    • the 'web content' field must be filled with a value,
    • or the web content must have an associated template.

 

 

Did this article resolve your issue ?

Legacy Knowledge Base