cancel
Showing results for 
Search instead for 
Did you mean: 

custom workflow difficulties

georgy
Champ in-the-making
Champ in-the-making
Hello
I'm having difficulties creating a custom advanced workflow. I've been working on it for well over a week, but don't fully understand all the facets of workflows.

We are using Alfrsco Community Edition 5.0a.

After making some changes today I am curently getting the error message:

org.activiti.engine.ActivitiIllegalArgumentException: org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener doesn't implement interface org.activiti.engine.delegate.ExecutionListener not interface org.activiti.engine.delegate.JavaDelegate

I created my workflow in the Activiti Designer in Eclipse. Here's the code:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="activiti_apaVPAprocess" name="APA/VPA Freigabe Workflow" isExecutable="true">
    <startEvent id="startEvent" name="Alfresco start" activiti:formKey="wf:submitAdhocTask"></startEvent>
    <userTask id="qp_assignReviewTask" name="assign review" activiti:assignee="frehner" activiti:formKey="wf:adhocTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_assignee', task.getVariable('bpm_assignee'));
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('abteilungsleiter', person);
execution.setVariable('bpm_dueDate', task.dueDate);
execution.setVariable('bpm_priority', task.priority);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="abtL_reviewTask" name="abtl_review" activiti:assignee="frehner" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('av_kab', person);
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('abtl_reviewOutcome', task.getVariable('abtl_reviewOutcome'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="av_reviewTask" name="av_review" activiti:assignee="keller" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('av_ReviewOutcome', task.getVariable('av_ReviewOutcome'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="documentsApproved" name="approved" activiti:assignee="frehner" activiti:formKey="wf:approvedTask">
      <documentation>Das Dokument wurde überprüft und genehmigt.
/ The document was reviewed and approved.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" name="1" sourceRef="startEvent" targetRef="qp_assignReviewTask"></sequenceFlow>
    <sequenceFlow id="flow2" name="2" sourceRef="qp_assignReviewTask" targetRef="abtL_reviewTask"></sequenceFlow>
    <exclusiveGateway id="reviewDecision1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow3" name="3" sourceRef="abtL_reviewTask" targetRef="reviewDecision1"></sequenceFlow>
    <sequenceFlow id="flow4" name="4" sourceRef="reviewDecision1" targetRef="av_reviewTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${abtl_reviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="reviewDecision2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow6" name="6" sourceRef="av_reviewTask" targetRef="reviewDecision2"></sequenceFlow>
    <sequenceFlow id="flow7" name="7" sourceRef="reviewDecision2" targetRef="documentsApproved">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${av_ReviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endEvent" name="End"></endEvent>
    <sequenceFlow id="flow10" name="10" sourceRef="documentsApproved" targetRef="endEvent"></sequenceFlow>
    <userTask id="rejected" name="rejected" activiti:assignee="frehner" activiti:formKey="wf:rejectedTask">
      <documentation>Das Dokument wurde überprüft und abgelehnt.
/ The document was reviewed and rejected.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow5" name="5" sourceRef="reviewDecision1" targetRef="rejected">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${abtl_reviewOutcome == 'Reject'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow8" name="8" sourceRef="reviewDecision2" targetRef="rejected">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${av_ReviewOutcome == 'Reject'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow9" name="9" sourceRef="rejected" targetRef="qp_assignReviewTask"></sequenceFlow>
  </process>


I am thankful for any help rendered or advice given, as I am struggling to get this workflow running.

Description of the intended workflow process:
-the initiator sends a document to user1 to be reviewd
-if approved, user1 sends the document to user 2 to be reviewed
-if the document was approved by user1 and 2, the approved document returns to the initiator who converts it to a PDF file
-if the document is rejected by either user it comes back to the initiator.

nice-to-have:
-if the document is not approved/rejected within x days it geta approved automatically and is sent to the initiator.


P.S. now I cannot deploy the xml, receiving the message "Exception in Transaction."
6 REPLIES 6

arak
Confirmed Champ
Confirmed Champ
Hi Georgy,

Can you copy and paste (or attach is better) the complete error log of your application server? this is for see more details.

Greetings
Pablo Arak.

georgy
Champ in-the-making
Champ in-the-making
I have gone through the Tutorials:
http://ecmarchitect.com/alfresco-developer-series-tutorials/workflow/tutorial/tutorial.html
http://jmuras.com/blog/2012/creation-of-workflow-in-alfresco-using-activiti-step-by-step/
although trying to implement my needs, instead of first doing it exactly as in the Tutorial.
I was not able to deploy the result of following the tutorial, until I removed a lot of the assignees and other code. The documentation on the alfresco website was also referenced.

I deploy the workflows through /alfresco/faces/jsp/admin/workflow.jsp after creating custom forms following the tuorial, but failing to automatically deploy everything. Even reading the Alfresco documentation on the website I am not sure where to add all the necessry code for deploying workflows automatically.

I tried adapting the activiti-adhoc-timer example by adding another UserTask to it, unsuccessfully.

While I am happy trying to learn all the facets involved in creating a custom workflow, my time to implement this one is running out. I would like to have this workflow working before my current internship ends, if possible. Sadly, nobody inhouse can help me.

One mistake which took me a long time to notice was that creating a UserTask from the 'ring' around the AlfrescoStartEvent (in the Activiti Designer)creates a normal UserTask, and not an AlfrescoUserTask. This caused a great deal of frustration as deplyoing a workflow model created with the Alfresco elements was much easier, and my first diagram created models all failed to deploy.

georgy
Champ in-the-making
Champ in-the-making
Attached is the Alfresco log
(I had to delete some entries, as it was greater than 2MB)

georgy
Champ in-the-making
Champ in-the-making
Hello again,
Thank you Pablo for your prompt reply. I hope that the log file can offer more insight.

Regards the error message
<blockcode>org.activiti.engine.ActivitiIllegalArgumentException: org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener doesn't implement interface org.activiti.engine.delegate.ExecutionListener not interface org.activiti.engine.delegate.JavaDelegate</blockcode>
In the Alfresco Designer I added the Listeneres as Task Listeners of Type 'Alfresco task script'.

georgy
Champ in-the-making
Champ in-the-making
Hello,
I will be making a lot of beginner mistakes I'm sure. This one was in keeping my previous, failed custom workflows deployed.

After I came across the following link I deleted all unnecessary workflow defnitions.
http://ecmarchitect.com/archives/2011/04/27/1357

This solved the following error:
<blockcode>org.activiti.engine.ActivitiIllegalArgumentException: org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener doesn't implement interface org.activiti.engine.delegate.ExecutionListener not interface org.activiti.engine.delegate.JavaDelegate</blockcode>

georgy
Champ in-the-making
Champ in-the-making
I have changed my code today.
As I have two decision gateways, I need to define two seperate variables for the two decision outcomes. I set each one in the task preceding a gateway with a
execution.setVariable('reviewOutcome', task.getVariable('reviewOutcome'))
.

I am getting the error message "No outgoing sequence flow of the exclusive …. could be selected for continueing the proces".

While I google for the solution I will still post my new code here. May be someone has time to look at it and has a quick answer  =O)

("Die Hoffnung stirbt zuletzt")   ("….aber sie stirbt.)


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="activiti_apaVPAprocess" name="APA/VPA Freigabe Workflow" isExecutable="true">
    <documentation>v.0.9</documentation>
    <startEvent id="startEvent" name="Alfresco start" activiti:formKey="wf:submitAdhocTask"></startEvent>
    <userTask id="qp_assignReviewTask" name="assign review" activiti:assignee="frehner" activiti:formKey="wf:adhocTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_assignee', task.getVariable('bpm_assignee'));
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('abteilungsleiter', person);
execution.setVariable('bpm_dueDate', task.dueDate);
execution.setVariable('bpm_priority', task.priority);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="abtL_reviewTask" name="abtl_review" activiti:assignee="frehner" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);
]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('av_kab', person);
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('abtl_reviewOutcome', task.getVariable('abtl_reviewOutcome'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="av_reviewTask" name="av_review" activiti:assignee="keller" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('av_ReviewOutcome', task.getVariable('av_ReviewOutcome'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="documentsApproved" name="approved" activiti:assignee="frehner" activiti:formKey="wf:approvedTask">
      <documentation>Das Dokument wurde überprüft und genehmigt.
/ The document was reviewed and approved.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" name="1" sourceRef="startEvent" targetRef="qp_assignReviewTask"></sequenceFlow>
    <sequenceFlow id="flow2" name="2" sourceRef="qp_assignReviewTask" targetRef="abtL_reviewTask"></sequenceFlow>
    <exclusiveGateway id="reviewDecision1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow3" name="3" sourceRef="abtL_reviewTask" targetRef="reviewDecision1"></sequenceFlow>
    <sequenceFlow id="flow4" name="4" sourceRef="reviewDecision1" targetRef="av_reviewTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${abtl_reviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="reviewDecision2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow6" name="6" sourceRef="av_reviewTask" targetRef="reviewDecision2"></sequenceFlow>
    <sequenceFlow id="flow7" name="7" sourceRef="reviewDecision2" targetRef="documentsApproved">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${av_ReviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endEvent" name="End"></endEvent>
    <sequenceFlow id="flow10" name="10" sourceRef="documentsApproved" targetRef="endEvent"></sequenceFlow>
    <userTask id="rejected" name="rejected" activiti:assignee="frehner" activiti:formKey="wf:rejectedTask">
      <documentation>Das Dokument wurde überprüft und abgelehnt.
/ The document was reviewed and rejected.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow5" name="5" sourceRef="reviewDecision1" targetRef="rejected">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${abtl_reviewOutcome == 'Reject'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow8" name="8" sourceRef="reviewDecision2" targetRef="rejected">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${av_ReviewOutcome == 'Reject'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow9" name="9" sourceRef="rejected" targetRef="qp_assignReviewTask"></sequenceFlow>
  </process>
</definitions>


I still need to find out the correct way of passing on the assignee in a workflow with several steps.