cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while Start a process using REST

sarkar92
Champ in-the-making
Champ in-the-making
I have created a simple process with two script task.
my 1st script task executed successfully and i  intentionally added arithmetic exception(Division by Zero) in my 2nd script task.

I am starting this process using REST by passing "processDefinationId".
so if my process start successfully i should get 200 but now i am getting 500 due to the Arithmetic exception.

Why should I worry about if there any exception in my process…. My REST call only return me if its successfully started the process or not.

is there any way in REST that i just start the process and came-out not worry about the exception in process.

my another question while getting exception in middle of the processinstance why the process not entered in "ACT_HI_PROCINST" table though my process started successfully??

  
  here is my process 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: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="errorProcess" name="Error Process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>System.out.println("result –&gt;"+3/1);

</script>
    </scriptTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>System.out.println("result –&gt;"+3/0);</script>
    </scriptTask>
    <sequenceFlow id="flow2" sourceRef="scripttask1" targetRef="scripttask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_errorProcess">
    <bpmndi:BPMNPlane bpmnElement="errorProcess" id="BPMNPlane_errorProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="70.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55.0" width="105.0" x="270.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="690.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask2" id="BPMNShape_scripttask2">
        <omgdc:Bounds height="55.0" width="105.0" x="530.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="105.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="375.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="530.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="635.0" y="247.0"></omgdi:waypoint>
        <omgdi:waypoint x="690.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
5 REPLIES 5

sarkar92
Champ in-the-making
Champ in-the-making
please help….

trademak
Star Contributor
Star Contributor
Hi,

When you only have synchronous activities the process is started successfully, but due to the script task error the whole transaction is rolled back and you end up in a state where no process instance is created, therefore you also see no entry in the history table. If you want the process to be started, you should make the script task asynchronous.
In case of the 500 status code, don't you get a http status error description as well?

Best regards,

sarkar92
Champ in-the-making
Champ in-the-making
thanks a lot Tijs .

in that case when an script task error occur can i end the process-instance with the custom delete reason like "error".

trademak
Star Contributor
Star Contributor
The delete reason is only filled, when you really delete the process instance. So in normal process execution you should not do this. What you can do is create an additional end event with a specific id. Then in the history you can query for process instances that have ended in this state.

Best regards,

sarkar92
Champ in-the-making
Champ in-the-making
thanks Tijs . its really help me