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

Adding JournalArticles through services or imports can cause freemarker errors



      Backporting LPS-99857 to 7.0.x revealed an issue where (harmless) freemarker errors are thrown: https://test-1-7.liferay.com/job/test-portal-acceptance-pullrequest-batch(7.0.x)/AXIS_VARIABLE=0,label_exp=!master/27977//consoleText

      LPS-99857 created a situation where JournalArticle templates will try to be rendered during an import. If the template needs information from a request, because there is no request during an import or service call, it will fail and throw freemarker errors. The clearest example is when deploying the porygon-theme.war to 7.0.x with the changes from LPS-99857. Because the war imports journal articles with a template which depends on attributes from the non-existent request, a long series of freemarker exceptions appear, one for each article.

      Reproduction Steps:

      1. Create a new site
      2. Goto Web Content and from the upper right ellipsis Export/Import
      3. Import Template Export.portlet.lar

      Expected Results: The import happens without throwing freemarker errors
      Actual Results: Freemarker errors are thrown in logs

      [exec] FreeMarker template error. See an example error below. 
           [exec] The following has evaluated to null or missing:
           [exec] ==> request.attributes  [in template "20115#20151#37564" at line 1, column 20]
           [exec] ----
           [exec] Tip: It's the step after the last dot that caused this error, not those before it.
           [exec] ----
           [exec] Tip: If the failing expression is known to be 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)??
           [exec] ----
           [exec] ----
           [exec] FTL stack trace ("~" means nesting-related):
           [exec] 	- Failed at: #assign colSize = request.attributes...  [in template "20115#20151#37564" at line 1, column 1]
           [exec] ----
           [exec] Java stack trace (for programmers):
           [exec] ----
           [exec] freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
           [exec] 	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131)
           [exec] 	at freemarker.core.UnexpectedTypeException.newDesciptionBuilder(UnexpectedTypeException.java:77)
           [exec] 	at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:40)
           [exec] 	at freemarker.core.NonHashException.<init>(NonHashException.java:46)
           [exec] 	at freemarker.core.Dot._eval(Dot.java:45)
           [exec] 	at freemarker.core.Expression.eval(Expression.java:78)
           [exec] 	at freemarker.core.DefaultToExpression._eval(DefaultToExpression.java:80)
           [exec] 	at freemarker.core.Expression.eval(Expression.java:78)
           [exec] 	at freemarker.core.Assignment.accept(Assignment.java:131)
           [exec] 	at freemarker.core.Environment.visit(Environment.java:324)
           [exec] 	at freemarker.core.MixedContent.accept(MixedContent.java:54)
           [exec] 	at freemarker.core.Environment.visit(Environment.java:324)
           [exec] 	at freemarker.core.Environment.process(Environment.java:302)
           [exec] 	at freemarker.template.Template.process(Template.java:325)
           [exec] 	at com.liferay.portal.template.freemarker.internal.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:139)
           [exec] 	at com.liferay.portal.template.AbstractSingleResourceTemplate.doProcessTemplate(AbstractSingleResourceTemplate.java:85)
           [exec] 	at com.liferay.portal.template.AbstractTemplate.write(AbstractTemplate.java:204)
           [exec] 	at com.liferay.portal.template.AbstractSingleResourceTemplate.processTemplate(AbstractSingleResourceTemplate.java:108)
           [exec] 	at com.liferay.journal.transformer.JournalTransformer.mergeTemplate(JournalTransformer.java:691)
           [exec] 	at com.liferay.journal.transformer.JournalTransformer.doTransform(JournalTransformer.java:346)
           [exec] 	at com.liferay.journal.transformer.JournalTransformer.transform(JournalTransformer.java:120)
           [exec] 	at com.liferay.journal.util.impl.JournalUtil.transform(JournalUtil.java:1193)
           [exec] 	at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:7466)
           [exec] 	at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2170)
           [exec] 	at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.notifySubscribers(JournalArticleLocalServiceImpl.java:7813)
           [exec] 	at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.updateStatus(JournalArticleLocalServiceImpl.java:6226)


        1. Template Export.portlet.lar
          10 kB
          Joshua Cords
        2. Template Export 7-0.portlet.lar
          7 kB
          Joshua Cords
        3. Template Export 7-1.portlet.lar
          9 kB
          Joshua Cords

          Issue Links



              yang.cao Yang Cao
              joshua.cords Joshua Cords
              Participants of an Issue:
              Recent user:
              Joel Garman
              Engineering Assignee:
              Joshua Cords
              0 Vote for this issue
              1 Start watching this issue


                Days since last comment:
                2 years, 40 weeks, 4 days ago


                  Version Package
                  7.0.0 DXP FP89
         DXP SP13
                  7.1.10 DXP FP16
                  7.2.10 DXP FP3
                  7.2.1 CE GA2
                  7.3.10 DXP GA1