cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti workflow not working on 4.01.

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I have created a pooled review workflow using activiti as below.

<?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: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://activiti.org/bpmn20">
  <process id="TestactivitiReviewPooled" name="Test Pooled Review And Approve Process">
    <startEvent id="start" activiti:formKey="wf:submitGroupReviewTask"></startEvent>
    <userTask id="reviewTask" name="Review Task" activiti:candidateGroups="${bpm_groupAssignee.properties.authorityName}" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>if (typeof bpm_workflowDueDate != 'undefined') task.setVariable('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
    <userTask id="approved" name="Document Approved" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:approvedTask">
      <documentation>
                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>if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('bpm_assignee', person);
</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="rejected" name="Document Rejected" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:rejectedTask">
      <documentation>
                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>if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('bpm_assignee', person);</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="end"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="start" targetRef="reviewTask"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="reviewDecision" targetRef="approved">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" name="" sourceRef="reviewDecision" targetRef="rejected"></sequenceFlow>
    <sequenceFlow id="flow5" name="" sourceRef="approved" targetRef="end"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="rejected" targetRef="end"></sequenceFlow>

    <serviceTask id="alfrescoMailtask1" name="Alfresco Mail Task" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string>var mail = actions.create("mail");
mail.parameters.to = abc@abc.com;
mail.parameters.subject = Test;
mail.parameters.from = abc@abc.com;
mail.parameters.text = Test123;
mail.execute(bpm_package);
</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>

    <sequenceFlow id="flow7" name="to Alfresco Mail Task" sourceRef="reviewTask" targetRef="alfrescoMailtask1"></sequenceFlow>
    <sequenceFlow id="flow8" name="to Review Decision" sourceRef="alfrescoMailtask1" targetRef="reviewDecision"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_TestactivitiReviewPooled">
    <bpmndi:BPMNPlane bpmnElement="TestactivitiReviewPooled" id="BPMNPlane_TestactivitiReviewPooled">
      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
        <omgdc:Bounds height="35" width="35" x="65" y="50"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewTask" id="BPMNShape_reviewTask">
        <omgdc:Bounds height="55" width="105" x="30" y="193"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
        <omgdc:Bounds height="40" width="40" x="460" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="approved" id="BPMNShape_approved">
        <omgdc:Bounds height="55" width="105" x="604" y="137"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="rejected" id="BPMNShape_rejected">
        <omgdc:Bounds height="55" width="105" x="604" y="254"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
        <omgdc:Bounds height="35" width="35" x="790" y="147"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoMailtask1" id="BPMNShape_alfrescoMailtask1">
        <omgdc:Bounds height="55" width="105" x="260" y="193"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="82" y="85"></omgdi:waypoint>
        <omgdi:waypoint x="82" y="193"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="480" y="200"></omgdi:waypoint>
        <omgdi:waypoint x="479" y="164"></omgdi:waypoint>
        <omgdi:waypoint x="604" y="164"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="480" y="240"></omgdi:waypoint>
        <omgdi:waypoint x="479" y="281"></omgdi:waypoint>
        <omgdi:waypoint x="604" y="281"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="709" y="164"></omgdi:waypoint>
        <omgdi:waypoint x="790" y="164"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="709" y="281"></omgdi:waypoint>
        <omgdi:waypoint x="807" y="281"></omgdi:waypoint>
        <omgdi:waypoint x="807" y="182"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="135" y="220"></omgdi:waypoint>
        <omgdi:waypoint x="260" y="220"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="365" y="220"></omgdi:waypoint>
        <omgdi:waypoint x="460" y="220"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

I can see this workflow in share & assign it to any content but when approver tries to approve/reject the content, it throws error as below.


May 30, 2012 5:15:27 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
   at org.apache.jsp.error500_jsp._jspService(error500_jsp.java:136)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:438)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:421)
   at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
   at java.lang.Thread.run(Thread.java:662)
May 30, 2012 5:15:27 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[errorCode=500, location=/error500.jsp]
org.apache.jasper.JasperException: java.lang.NullPointerException
   at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:438)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:421)
   at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
   at org.apache.jsp.error500_jsp._jspService(error500_jsp.java:136)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
   … 19 more

And on share i can see pop showing failure. But when i remove email task,which i need , it works fine?

Syntactically, it seems to be fine, can anyone help me ahy email part is not working? I am using alfrescoMailtask without sucess and used simple mailtask with no success.

Can anyone help?

Regards.
6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
Just a hunch: Do you have an outbound mail.host specified in alfresco-global.properties?

If that's not it you may have to hook up the debugger.

Jeff

dynamolalit
Champ on-the-rise
Champ on-the-rise
Thanks Jeff,

I have set up outbound email configurations as below.

### Outbound Email Configuration ###
mail.protocol=smtp
mail.host=localhost
mail.port=25
mail.username=
mail.password=
mail.from.default=admin@alfresco.com
mail.smtps.starttls.enable=false
mail.smtps.auth=false
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory

Is there anything more needed to be done? How to debug in this case?

Regards.

jpotts
World-Class Innovator
World-Class Innovator
I don't know for sure if this is your problem, but in the past I have had problems when using "localhost" as mail.host. If you are testing locally, I suggest you use the name that is returned when you type "hostname" on the command-line, or use an entry from the /etc/hosts file that is bound to 127.0.0.1. For example, I added an entry in my hosts file like this:
127.0.0.1   jpotts.alfresco-laptop.com

And then I use "jpotts.alfresco-laptop.com" as the value for mail.host.

Also, do you have an SMTP server running on localhost? For example, when I need to test email actions I use Apache James running locally. Then I set up Thunderbird to retrieve mail via POP3 from my local Apache James server.

If that doesn't fix your problem, the way you debug is to configure Eclipse and your Tomcat server for remote debugging. Then you can set a breakpoint and step through your code. What's weird is that your stacktrace isn't showing any Alfresco package names, so that isn't going to help you determine where to set the breakpoint. Not sure how to help you there.

Jeff

angello0571
Champ on-the-rise
Champ on-the-rise
Hi everyone!

I am here to request your help one more time. I checked in the forum and someone put a wiki link with this page http://wiki.alfresco.com/wiki/Workflow_with_Activiti.
That is a great example where explain how to send an email in a userTask event because the activiti's emailTask does not work.
I did the example and it works perfectly into the listener of userTask.

Well, my requirement is the next one:

I'm doing a workflow, it has a boundary timer in a user task that after 1 minute should send
an email if the task has not been completed yet. I figure out to use a scriptTask to trigger the email into the start event.
Let me show you:
<!– Using a Script task –>
<scriptTask id="scripttask1" name="Send Email" scriptFormat="javascript">
        <extensionElements>
         <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
           <activiti:field name="script">
            <activiti:string>
                var mail = actions.create("mail");
                mail.parameters.to = "a@gmail.com";
                mail.parameters.subject = "send a workflow's email. second test! " + bpm_workflowDescription;
                mail.parameters.from = "b@gmail.com";
                mail.parameters.text = "2nd Test message! ";
                mail.execute(bpm_package);
            </activiti:string>
           </activiti:field>
         </activiti:executionListener>
        </extensionElements>
        <script><![CDATA[]]></script>
      </scriptTask>
When the boundary timer runs, I got an exception:
Exception in thread "pool-1-thread-4" org.activiti.engine.ActivitiException: org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener doesn't implement interface org.activiti.engine.delegate.ExecutionListener nor interface org.activiti.engine.delegate.JavaDelegate
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getExecutionListenerInstance(ClassDelegate.java:80)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:66)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:38)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)   
I did a second try using this:   
<!– Using the alfresco's Script task –>
<scriptTask id="scripttask1" name="Send Email" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
  <extensionElements>
     <activiti:field name="script">
      <activiti:string>
             var mail = actions.create("mail");
             mail.parameters.to = "a@gmail.com";
             mail.parameters.subject = "send a workflow's email. second test! " + bpm_workflowDescription;
             mail.parameters.from = "b@gmail.com";
             mail.parameters.text = "2nd Test message! ";
             mail.execute(bpm_package);
      </activiti:string>
     </activiti:field>
  </extensionElements>
</scriptTask>
Again I get an exception:
Exception in thread "pool-1-thread-1" java.lang.NullPointerException
   at javax.script.ScriptEngineManager.getEngineByName(ScriptEngineManager.java:199)
   at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:63)
   at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:43)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)

Does anybody could help me with a "tip" or a way to solve this ?
Maybe I'm not using the correct Class, or I have to use another component, anyway. I'll be alert of any help.
Thanks in advance guys.

haroldvera
Champ in-the-making
Champ in-the-making
Activiti within alfresco for the ScriptTask not access the alfresco model, take your code to sequenceFlow or UserTask.

<sequenceFlow id="flow18" name="" sourceRef="parallelgateway1" targetRef="exclusivegateway2">
      <extensionElements>
        <activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
          <activiti:field name="script">
            <activiti:string>var mail = actions.create("mail");
              mail.parameters.to = "a@gmail.com";
              mail.parameters.subject = "send a workflow's email. second test! " + bpm_workflowDescription;
              mail.parameters.from = "b@gmail.com";
              mail.parameters.text = "2nd Test message! ";
              mail.execute(bpm_package);
             </activiti:string>
          </activiti:field>
        </activiti:executionListener>
      </extensionElements>
    </sequenceFlow>

peadair
Champ in-the-making
Champ in-the-making
Hi dynamolalit,
    I also have the same nullpointerException.

I have alfresco.global.properties set as:


### SMTP mail server settings
mail.host=outlookDub.xxxxx.net

This was working fine up until recently and I've not made any changes that should impact on it yet I'm now getting:



SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
   at org.apache.jsp.error500_jsp._jspService(error500_jsp.java:136)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:438)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:421)
   at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:662)

….stacktrace on on tomcat-share.

Did you manage to uncover the issue?

Thanks,
Peter.