Problem with freemarker in folder rule with Send Email

cancel
Showing results for 
Search instead for 
Did you mean: 
faobek
Active Member II

Problem with freemarker in folder rule with Send Email

Hi,

I tray to put a rule on a folder with sending an email like a notification, all things are ok, but when the mail is received we haven't right retun (pl. see the capture), we think it's about freemarker problem on html page.

thanks a lo

rule3.jpg)

7 Replies
cesarista
Customer

Re: Problem with freemarker in folder rule with Send Email

Hi:

Some questions:

 - May you indicate how you create content rule ? Maybe with a JS snippet?. You may debug the FTL output for JS code with the help of Javascript Console addon.

 - Did you try the rule and the email without ftl template (text message) ? Does it work properly?

 - May you include the error logs (catalina.out) if any ?

Regards.

--C. 

faobek
Active Member II

Re: Problem with freemarker in folder rule with Send Email

Hi,

thanks a lot for your reply.

I create a simple folder rule, Manage Rules>Create Rule>In Send Email (Action) (see capture); Ihave tried to use .ftl file but it rule4.jpgdidn't work, I have idea to copy and past it in Message Field (like in capture), the result was what I send yesterday.

Best Regards ,

faobek
Active Member II

Re: Problem with freemarker in folder rule with Send Email

Hi,

I add the alfresco log file.

2022-11-07 00:00:01,658 ERROR [freemarker.runtime] [FeedNotifier1] Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> {activity.activitySummary.pag [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 130]

Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

The failing instruction (FTL stack trace):
----------
==> ${activity.activitySummary.page?html!""} [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 128]
#assign itemLink = "\la href=\"\${sha... [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 49]
----------

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.StringBuiltins$StringBuiltIn._eval(StringBuiltins.java:87)
at freemarker.core.Expression.eval(Expression.java:111)
at freemarker.core.DefaultToExpression._eval(DefaultToExpression.java:116)
at freemarker.core.Expression.eval(Expression.java:111)
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.visit(Environment.java:265)
at freemarker.core.Environment.renderElementToString(Environment.java:1798)
at freemarker.core.StringLiteral.evalAndCoerceToString(StringLiteral.java:116)
at freemarker.core.StringLiteral._eval(StringLiteral.java:93)
at freemarker.core.Expression.eval(Expression.java:111)
at freemarker.core.Assignment.accept(Assignment.java:106)
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.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.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.Environment.process(Environment.java:243)
at org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:230)
at org.alfresco.repo.processor.TemplateServiceImpl.processTemplate(TemplateServiceImpl.java:184)
at org.alfresco.repo.processor.TemplateServiceImpl.processTemplate(TemplateServiceImpl.java:247)
at org.alfresco.repo.action.executer.MailActionExecuter$3.prepare(MailActionExecuter.java:965)
at org.alfresco.repo.action.executer.MailActionExecuter.prepareEmail(MailActionExecuter.java:1026)
at org.alfresco.repo.action.executer.MailActionExecuter.prepareEmails(MailActionExecuter.java:585)
at org.alfresco.repo.action.executer.MailActionExecuter.executeImpl(MailActionExecuter.java:490)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:79)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy290.execute(Unknown Source)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:856)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:757)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:581)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:567)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:865)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:41)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:166)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy41.executeAction(Unknown Source)
at org.alfresco.repo.activities.feed.EmailUserNotifier.notifyUser(EmailUserNotifier.java:187)
at org.alfresco.repo.activities.feed.AbstractUserNotifier.notifyUser(AbstractUserNotifier.java:228)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.processInternal(FeedNotifierImpl.java:393)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.access$2(FeedNotifierImpl.java:388)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1$1.execute(FeedNotifierImpl.java:379)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1$1.execute(FeedNotifierImpl.java:1)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1.doWork(FeedNotifierImpl.java:375)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1.doWork(FeedNotifierImpl.java:1)
at org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:126)
at org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:95)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.process(FeedNotifierImpl.java:370)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.process(FeedNotifierImpl.java:1)
at org.alfresco.repo.batch.BatchProcessor$TxnCallback.execute(BatchProcessor.java:720)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
at org.alfresco.repo.batch.BatchProcessor$TxnCallback.run(BatchProcessor.java:764)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2022-11-07 00:00:01,701 ERROR [freemarker.runtime] [FeedNotifier1] Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> {activity.activitySummary.pag [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 130]

Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

The failing instruction (FTL stack trace):
----------
==> ${activity.activitySummary.page?html!""} [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 128]
#assign itemLink = "\la href=\"\${sha... [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 49]
----------

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.StringBuiltins$StringBuiltIn._eval(StringBuiltins.java:87)
at freemarker.core.Expression.eval(Expression.java:111)
at freemarker.core.DefaultToExpression._eval(DefaultToExpression.java:116)
at freemarker.core.Expression.eval(Expression.java:111)
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.visit(Environment.java:265)
at freemarker.core.Environment.renderElementToString(Environment.java:1798)
at freemarker.core.StringLiteral.evalAndCoerceToString(StringLiteral.java:116)
at freemarker.core.StringLiteral._eval(StringLiteral.java:93)
at freemarker.core.Expression.eval(Expression.java:111)
at freemarker.core.Assignment.accept(Assignment.java:106)
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.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.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.Environment.process(Environment.java:243)
at org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:230)
at org.alfresco.repo.processor.TemplateServiceImpl.processTemplate(TemplateServiceImpl.java:184)
at org.alfresco.repo.processor.TemplateServiceImpl.processTemplate(TemplateServiceImpl.java:247)
at org.alfresco.repo.action.executer.MailActionExecuter$3.prepare(MailActionExecuter.java:965)
at org.alfresco.repo.action.executer.MailActionExecuter.prepareEmail(MailActionExecuter.java:1026)
at org.alfresco.repo.action.executer.MailActionExecuter.prepareEmails(MailActionExecuter.java:585)
at org.alfresco.repo.action.executer.MailActionExecuter.executeImpl(MailActionExecuter.java:490)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:79)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy290.execute(Unknown Source)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:856)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:757)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:581)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:567)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:865)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:41)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:166)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy41.executeAction(Unknown Source)
at org.alfresco.repo.activities.feed.EmailUserNotifier.notifyUser(EmailUserNotifier.java:187)
at org.alfresco.repo.activities.feed.AbstractUserNotifier.notifyUser(AbstractUserNotifier.java:228)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.processInternal(FeedNotifierImpl.java:393)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.access$2(FeedNotifierImpl.java:388)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1$1.execute(FeedNotifierImpl.java:379)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1$1.execute(FeedNotifierImpl.java:1)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1.doWork(FeedNotifierImpl.java:375)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2$1.doWork(FeedNotifierImpl.java:1)
at org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:126)
at org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:95)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.process(FeedNotifierImpl.java:370)
at org.alfresco.repo.activities.feed.FeedNotifierImpl$2.process(FeedNotifierImpl.java:1)
at org.alfresco.repo.batch.BatchProcessor$TxnCallback.execute(BatchProcessor.java:720)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:464)
at org.alfresco.repo.batch.BatchProcessor$TxnCallback.run(BatchProcessor.java:764)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2022-11-07 00:00:01,851 ERROR [freemarker.runtime] [FeedNotifier1] Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> {activity.activitySummary.pag [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 130]

Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

The failing instruction (FTL stack trace):
----------
==> ${activity.activitySummary.page?html!""} [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 128]
#assign itemLink = "\la href=\"\${sha... [in template "workspace://SpacesStore/30d6545c-c332-4abf-b5cc-67297d7f1ac2" at line 53, column 49]
----------

 

cesarista
Customer

Re: Problem with freemarker in folder rule with Send Email

Hi:

I think it is a problem with the chosen ftl.

Try not to choose an activities related ftl, some notify_user_email.html.ftl should work.

Regards.

--C.

 

faobek
Active Member II

Re: Problem with freemarker in folder rule with Send Email

thanks a lot for your support,

I already tried many ftl sample, but with the same result.

more further information, when a receive a alfresco user notification mail (see capture), the result seems good.

perhaps there's more configuration to perform when used SendEmail in folder Rule?

Best Regards,

rule5.jpg

cesarista
Customer

Re: Problem with freemarker in folder rule with Send Email

Hi:

You may try also something like this, using content rule that runs a JS Script.

https://angelborroy.wordpress.com/2015/05/22/alfresco-sending-a-notification-email-to-site-administr...

The example uses a custom ftl in Data Dictionary.

Regards.

--C.

 

 

faobek
Active Member II

Re: Problem with freemarker in folder rule with Send Email

Hi,

I already used this js, but i have an other problem , I spent a hours without result.

the Message error was in this way :

org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: No MimeMessage content; message exceptions (1)

Perhaps you have a clue in this.

Thanks a lot.