<?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 Custom task listener in Java in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/custom-task-listener-in-java/m-p/70237#M23108</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the simple following Workflow :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;lt;extensionElements&amp;gt;&lt;BR /&gt; &amp;lt;activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"&amp;gt;&lt;BR /&gt; &amp;lt;activiti:field name="script"&amp;gt;&lt;BR /&gt; &amp;lt;activiti:string&amp;gt;&amp;lt;![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);&lt;BR /&gt; if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;&lt;/P&gt;&lt;P&gt;// logger.system.out("task.getVariable(reviewAssignee) onCreate : "+task.getVariable("reviewAssignee"));]]&amp;gt;&amp;lt;/activiti:string&amp;gt;&lt;BR /&gt; &amp;lt;/activiti:field&amp;gt;&lt;BR /&gt; &amp;lt;/activiti:taskListener&amp;gt;&lt;BR /&gt; &amp;lt;activiti:taskListener event="complete" class="&lt;STRONG&gt;com.mc.huissier.workflow.WorkFlowTaskListene&lt;/STRONG&gt;r"&amp;gt;&amp;lt;/activiti:taskListener&amp;gt;&lt;BR /&gt; &amp;lt;/extensionElements&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;WorkFlowTaskListener java class :&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;public class WorkFlowTaskListener implements TaskListener {&lt;BR /&gt;&lt;BR /&gt; private static Logger logger = LoggerFactory.getLogger(WorkFlowTaskListener.class);&lt;/P&gt;&lt;P&gt;@Autowired&lt;BR /&gt; private WorkFlowServices workflowServices;&lt;BR /&gt; &lt;BR /&gt; @Autowired&lt;BR /&gt; private ServiceRegistry serviceRegistry;&lt;BR /&gt; &lt;BR /&gt; @Override&lt;BR /&gt; public void notify(DelegateTask task) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; DelegateExecution execution = task.getExecution();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; String reviewAction = task.getVariable("wfvd_reviewAction").toString();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; String nomService = task.getVariable("wfvd_nomService").toString();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; String fileName = task.getVariable("bpm_workflowDescription").toString(); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; ActivitiScriptNode scriptNode =&amp;nbsp; &amp;nbsp;(ActivitiScriptNode)execution.getVariable(WorkflowNotificationUtils.PROP_PACKAGE);&lt;BR /&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;logger.info("scriptNode OK !" + scriptNode);&lt;BR /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;NodeRef packagenode = scriptNode.getNodeRef();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; logger.info("packagenode OK !" + packagenode);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if(reviewAction.equals("CLA")) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("WorkFlowTaskListener : Classement du document");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String client = task.getVariable("wfvd_client").toString();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String typologie = task.getVariable("wfvd_typologie").toString();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String docDate = task.getVariable("wfvd_docDate").toString();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String mandataire = task.getVariable("wfvd_mandataire").toString();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("client: " + client);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("typologie: " + typologie);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("date: " + docDate);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.info("mandataire: " + mandataire);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Mise à jour des métadonnées&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;workflowServices.documentUpdate(packagenode, client, mandataire, typologie, docDate);&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} catch (Exception e) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.error("WorkFlowTaskListener - Erreur lors du classement : " + ExceptionUtils.getStackTrace(e));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an issue when documentUpdate method is called :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;WorkFlowTaskListener - Erreur lors du classement : java.lang.NullPointerException&lt;BR /&gt; at com.mc.huissier.workflow.WorkFlowTaskListener.notify(WorkFlowTaskListener.java:78)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's like if my workflowServices customed Class was unknown&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WorFlowServices.java :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;@Service&lt;BR /&gt;public class WorkFlowServices {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; private static final Logger logger = LoggerFactory.getLogger(WorkFlowServices.class);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; @Autowired&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;private CoreServices coreServices;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;@Autowired&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private FolderServices folderServices;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;@Autowired&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private FileFolderService fileFolderService;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; @Autowired&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;private NodeService nodeService;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public void documentUpdate(final NodeRef nodeDocumed, final String client, final String mandataire,&lt;BR /&gt; final String typeDoc, final String docDateStr) {&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork&amp;lt;Object&amp;gt;() {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public Object doWork() throws Exception {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;logger.debug("WorkFlowServices - documentUpdate - mise à jour des metadonnées");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date docDate = formatter.parse(docDateStr);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nodeService.setProperty(nodeDocumed, CoreServices.PROP_TYPOLOGIE, typeDoc);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nodeService.setProperty(nodeDocumed, CoreServices.PROP_DOCDATE, docDate);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nodeService.setProperty(nodeDocumed, CoreServices.PROP_CLIENT, client);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nodeService.setProperty(nodeDocumed, CoreServices.PROP_MANDATAIRE, mandataire);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return null;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}, AuthenticationUtil.getSystemUserName());&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The setence :&amp;nbsp;&lt;STRONG style="background-color: #f6f6f6;"&gt;"WorkFlowServices - documentUpdate - mise à jour des metadonnées"&amp;nbsp; doesn't appear in Log File&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #f6f6f6;"&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So I suppose the problem is about method or class definition&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Sep 2018 09:59:37 GMT</pubDate>
    <dc:creator>anakin59490</dc:creator>
    <dc:date>2018-09-03T09:59:37Z</dc:date>
    <item>
      <title>Custom task listener in Java</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/custom-task-listener-in-java/m-p/70237#M23108</link>
      <description>Hi,I have the simple following Workflow :&amp;lt;extensionElements&amp;gt; &amp;lt;activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"&amp;gt; &amp;lt;activiti:field name="script"&amp;gt; &amp;lt;activiti:string&amp;gt;&amp;lt;![CDATA[if (typeof bpm_workflowDueDate != 'undef</description>
      <pubDate>Mon, 03 Sep 2018 09:59:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/custom-task-listener-in-java/m-p/70237#M23108</guid>
      <dc:creator>anakin59490</dc:creator>
      <dc:date>2018-09-03T09:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Custom task listener in Java</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/custom-task-listener-in-java/m-p/70238#M23109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That exception message is likely a standard Java / Activiti exception message wrapped around the NullPointerException. The problem in your case is likely related to your use of annotations for configuration. Activiti inside of Alfresco (the embedded workflow engine) does not support configuration by annotation, and as such, all of your services that you specified via Autowired will not be set, causing NullPointerException upon access. You need to use Spring XML to define an instance of your listener, expose that bean to the Activiti engine, and then use a delegate expression instead of the class name to pick up the configured instance as a listener.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2018 08:16:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/custom-task-listener-in-java/m-p/70238#M23109</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2018-09-04T08:16:49Z</dc:date>
    </item>
  </channel>
</rss>

