<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error executing FreeMarker template in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127730#M34685</link>
    <description>&lt;P&gt;Please share with us your code or what results are you expecting.&lt;/P&gt;&lt;P&gt;When you add a contraint in a model you need to manage the view too. Usually, it's defined under share-config-custom.xml (to display under Share UI). Did you develop this part?&lt;/P&gt;&lt;P&gt;More info &lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html" target="_blank" rel="noopener nofollow noreferrer"&gt;here&lt;/A&gt; and &lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#part-2-configuring-alfresco-share" target="_blank" rel="noopener nofollow noreferrer"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 09:44:09 GMT</pubDate>
    <dc:creator>cristinamr</dc:creator>
    <dc:date>2021-08-20T09:44:09Z</dc:date>
    <item>
      <title>Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127727#M34682</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm doing some practice with Alfresco 5.2 (Community), to understand its mechanisms.&lt;/P&gt;&lt;P&gt;I'm trying to understand the customizable constraints through Java class, and to do this I followed (slightly adapting it) the example provided at this link&amp;nbsp; &lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-hub/content-model-constraints/ba-p/289687" target="_self" rel="nofollow noopener noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-hub/content-model-constraints/ba-p/289687&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But when I open the form the console returns the Error executing FreeMarker template error&lt;/P&gt;&lt;P&gt;What am I doing wrong? I am attaching content model, java class and console log.&lt;/P&gt;&lt;P&gt;CONTENT MODEL&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&amp;lt;constraints&amp;gt;
     &amp;lt;constraint name="trbar:FactorsOf" type="com.went.platformsample.Multipli"&amp;gt;&lt;BR /&gt;         &amp;lt;parameter name="multipleOf"&amp;gt;&amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;&amp;lt;/parameter&amp;gt;
     &amp;lt;/constraint&amp;gt;&lt;BR /&gt;&amp;lt;/constraints&amp;gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;lt;property name="trbar:Eta"&amp;gt;
	&amp;lt;title&amp;gt;Età&amp;lt;/title&amp;gt;
	&amp;lt;description&amp;gt;Età&amp;lt;/description&amp;gt;
	&amp;lt;type&amp;gt;d:int&amp;lt;/type&amp;gt;
	&amp;lt;mandatory&amp;gt;true&amp;lt;/mandatory&amp;gt;
	&amp;lt;index enabled="true"&amp;gt;
		&amp;lt;tokenised&amp;gt;true&amp;lt;/tokenised&amp;gt;
		&amp;lt;facetable&amp;gt;true&amp;lt;/facetable&amp;gt;
	&amp;lt;/index&amp;gt;
	&amp;lt;constraints&amp;gt;
		&amp;lt;constraint ref="trbar:FactorsOf" /&amp;gt;
	&amp;lt;/constraints&amp;gt;
&amp;lt;/property&amp;gt;&lt;/PRE&gt;&lt;P&gt;Multipli.java&lt;/P&gt;&lt;PRE&gt;package com.went.platformsample;

import java.util.HashMap;
import java.util.Map;

import org.alfresco.service.cmr.dictionary.Constraint;

public class Multipli implements Constraint {
	private Integer multipleOf = 0;

	@Override
	public Map&amp;lt;String, Object&amp;gt; getParameters() {

		System.out.println("getParameters");

		System.out.println("1 valore di multipleOf = " + multipleOf);
		System.out.println("2 valore di multipleOf = " + this.multipleOf);
		Map&amp;lt;String, Object&amp;gt; params = new HashMap&amp;lt;String, Object&amp;gt;(2);

		params.put("multipleOf", this.multipleOf);
		
		System.out.println("3 valore di multipleOf = " + params.get("multipleOf"));
		
		System.out.println("Params = " + params);
		
		return params;
	}

	@Override
	public String getType() {
		System.out.println("getType");
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTitle() {
		System.out.println("getTitle");
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getShortName() {
		System.out.println("getShortName");
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void initialize() {
		System.out.println("initialize");
		// TODO Auto-generated method stub

	}

	@Override
	public void evaluate(Object value) {
		System.out.println("evaluate");
		// TODO Auto-generated method stub

	}

	public Integer getMultipleOf() {
		System.out.println("getMultipleOf " + multipleOf);
		return multipleOf;
	}

	public void setMultipleOf(Integer multipleOf) {
		System.out.println("setMultipleOf " + multipleOf);
		this.multipleOf = multipleOf;
	}

}&lt;/PRE&gt;&lt;P&gt;Console log&lt;/P&gt;&lt;PRE&gt;2021-08-20 09:40:21,110  ERROR [freemarker.runtime] [http-bio-8080-exec-13] Error executing FreeMarker template
 FreeMarker template error:
The following has evaluated to null or missing:
==&amp;gt; jsonUtils.encodeJSONString(x)  [in template "org/alfresco/repository/forms/formdefinition.lib.ftl" at line 14, column 15]

Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use &amp;lt;#if myOptionalVar??&amp;gt;when-present&amp;lt;#else&amp;gt;when-missing&amp;lt;/#if&amp;gt;. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

The failing instruction (FTL stack trace):
----------
==&amp;gt; ${cnstrnt.type} auto-escaped  [in template "org/alfresco/repository/forms/formdefinition.lib.ftl" in macro "formDefJSON" at line 45, column 36]
    #if field.dataType??  [in template "org/alfresco/repository/forms/formdefinition.lib.ftl" in macro "formDefJSON" at line 36, column 21]
    @formDefLib.formDefJSON form=form  [in template "org/alfresco/repository/forms/formdefinition.post.json.ftl" at line 2, 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:98)
	at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:382)
	at freemarker.core.Expression.evalAndCoerceToString(Expression.java:115)
	at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:193)
	at freemarker.core.Environment.visitIteratorBlock(Environment.java:509)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:103)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:86)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.IfBlock.accept(IfBlock.java:84)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:193)
	at freemarker.core.Environment.visitIteratorBlock(Environment.java:509)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:103)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.EscapeBlock.accept(EscapeBlock.java:85)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.Macro$Context.runMacro(Macro.java:209)
	at freemarker.core.Environment.visit(Environment.java:694)
	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:116)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.MixedContent.accept(MixedContent.java:93)
	at freemarker.core.Environment.visit(Environment.java:265)
	at freemarker.core.Environment.process(Environment.java:243)
	at org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:230)
	at org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:967)
	at org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
	at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
	at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:512)
	at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
	at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:587)
	at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:656)
	at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:428)
	at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:308)
	at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:399)
	at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
	at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:68)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
2021-08-20 09:40:21,125  ERROR [extensions.webscripts.AbstractRuntime] [http-bio-8080-exec-13] Exception from executeScript: 07200002 Wrapped Exception (with status template): 07200019 Errore durante l'elaborazione del modello 'The following has evaluated to null or missing:
==&amp;gt; jsonUtils.encodeJSONString(x)  [in template "org/alfresco/repository/forms/formdefinition.lib.ftl" at line 14, column 15]&lt;/PRE&gt;&lt;P&gt;The impression is that the error is generated when the "return params;" at the end of the Map method.&lt;/P&gt;&lt;P&gt;Thanks in advance for the help.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 07:59:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127727#M34682</guid>
      <dc:creator>P_Giannuzzi</dc:creator>
      <dc:date>2021-08-20T07:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127728#M34683</link>
      <description>&lt;P&gt;It's failling the view because the value is missing or null. How are you getting and displaying those values?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:10:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127728#M34683</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-08-20T09:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127729#M34684</link>
      <description>&lt;P&gt;I had thought of this too, and in fact I put some logs on the console, and the log I print just before "return params;" shows the content of the object correctly valued.&lt;/P&gt;&lt;P&gt;The impression is that something is missing, but I can't understand what.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:18:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127729#M34684</guid>
      <dc:creator>P_Giannuzzi</dc:creator>
      <dc:date>2021-08-20T09:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127730#M34685</link>
      <description>&lt;P&gt;Please share with us your code or what results are you expecting.&lt;/P&gt;&lt;P&gt;When you add a contraint in a model you need to manage the view too. Usually, it's defined under share-config-custom.xml (to display under Share UI). Did you develop this part?&lt;/P&gt;&lt;P&gt;More info &lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html" target="_blank" rel="noopener nofollow noreferrer"&gt;here&lt;/A&gt; and &lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#part-2-configuring-alfresco-share" target="_blank" rel="noopener nofollow noreferrer"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 09:44:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127730#M34685</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-08-20T09:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127731#M34686</link>
      <description>&lt;P&gt;The view part I have already developed and, before I added this constraint to the content-model, it worked perfectly.&lt;/P&gt;&lt;P&gt;Furthermore, the guide I found from which I tried to generate the constraint does not say in any way (nor have I found other references) of the views.&lt;/P&gt;&lt;P&gt;But as I said, I am convinced that something is missing but I don't understand what.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 12:08:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127731#M34686</guid>
      <dc:creator>P_Giannuzzi</dc:creator>
      <dc:date>2021-08-20T12:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127732#M34687</link>
      <description>&lt;P&gt;Share with us the view part &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 13:36:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127732#M34687</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-08-20T13:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error executing FreeMarker template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127733#M34688</link>
      <description>&lt;P&gt;This is the part affected by the constraint, which worked correctly before I applied it.&lt;/P&gt;&lt;P&gt;In addition, I have also defined the other evaluator.&lt;/P&gt;&lt;PRE&gt;&amp;lt;config condition="trbar:IusPrimeNoctis" evaluator="model-type"&amp;gt;
		&amp;lt;forms&amp;gt;
			&amp;lt;form&amp;gt;
				&amp;lt;field-visibility&amp;gt;
					&amp;lt;show id="trbar:Eta" /&amp;gt;
				&amp;lt;/field-visibility&amp;gt;
				&amp;lt;appearance&amp;gt;
					&amp;lt;set appearance="whitespace" id="trbar:IusPrimeNoctis_cmm_set0" /&amp;gt;
					&amp;lt;field id="trbar:Eta" set="trbar:IusPrimeNoctis_cmm_set0"&amp;gt;&amp;lt;/field&amp;gt;

				&amp;lt;/appearance&amp;gt;
			&amp;lt;/form&amp;gt;
			
		&amp;lt;/forms&amp;gt;
	&amp;lt;/config&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Aug 2021 13:52:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-executing-freemarker-template/m-p/127733#M34688</guid>
      <dc:creator>P_Giannuzzi</dc:creator>
      <dc:date>2021-08-20T13:52:06Z</dc:date>
    </item>
  </channel>
</rss>

