Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-128456

FreeMarker template error occurs when the template contains Site ID variable


    Step to reproduce:

    1. Add a web content based on Basic Web Content
    2. Add a new template for Basic Web Content
    3. Select Site ID variable and Content field
    4. Type name > Save
    5. Add a page based on Blank
    6. Add a Content Display fragment to page
    7. Select the web content in Content Display
    8. Select the new template in Template field

    Expected Results:
    The groupId and content of web content should be shown in Content Display.

    Actual Results:
    The following freemarker template error occurs.

    2021-03-01 03:07:23.971 ERROR [http-nio-8080-exec-7][runtime:59] Error executing FreeMarker template
    FreeMarker template error:
    The following has evaluated to null or missing:
    ==> groupId  [in template "20100#20126#null" at line 1, column 3]
    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: ${groupId}  [in template "20100#20126#null" at line 1, column 1]
    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)

    Reproduced on:
    Tomcat 9.0.40 + MySQL 5.7. Portal master GIT ID: b82ae9277239522445506e58e59a2fedf8bce42d.


        Issue Links



            yang.cao Yang Cao
            yang.cao Yang Cao
            Participants of an Issue:
            Recent user:
            Sophia Zhang
            Engineering Assignee:
            J├╝rgen Kappler
            0 Vote for this issue
            0 Start watching this issue


              Days since last comment:
              1 year, 11 weeks, 5 days ago


                Version Package
                7.4.0 CE GA1 DXP 7,4
                7.4.13 DXP GA1