cancel
Showing results for 
Search instead for 
Did you mean: 

Upgrade to 5.16 with error on workflows : the target isn't defined in the same scope as the source

mapor
Champ in-the-making
Champ in-the-making
Hello,

I have upgrade to version 5.16 and got this error on my workflow.

The error comes on flow that link a boundary event attached in a sub process to a service task in the subprocess.
I need the variable hold by the sub process.

The workflow is designed using the bpmn designer of eclipse.

Sample of XML generated by eclipse:


     <subProcess id="userValidation" name="User Validation">
         [….]
    </subProcess>
    <boundaryEvent id="reminderTimer" name="Reminder Timer" attachedToRef="userValidation" cancelActivity="false">
      <timerEventDefinition>
        <timeCycle>R/P7D</timeCycle>
      </timerEventDefinition>
    </boundaryEvent>
<sequenceFlow id="flow27" sourceRef="reminderTimer" targetRef="servicetask1"></sequenceFlow>
      <serviceTask id="servicetask1" name="Send Reminder Task" activiti:async="true" activiti:exclusive="false" activiti:expression="#{mailingDelegate.sendValidationMail(execution, validationMailId, user)}"></serviceTask>


I guessed that the flows have to be in the sub process tag to be validated but when i do that i got a NPE from FlowNodeHistoryParseHandler.

ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId());


This line return a null ActivityImpl

Is it possible to disable validation first since the workflow worked well in 5.15.1

Process definition :

<?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://activiti.org/bpmn20">
  <signal id="cancelRequest" name="cancelRequest"></signal>
  <process id="genericRequest" name="genericRequest" isExecutable="true">
    <documentation>General workflow to validate any type of request
         - requestInitiator :
         initiator of
         the request (for tracability)
         - requestDelegated : either
         initiator of
         the request or delegated
         people (admin on behalf of the
         initiator)
         -
         validationUsers : list of users that must validate the
         request
         TODO :
         before mail task in subprocess : check for "deputy" +
         reassign if
         needed or canceled the whole task</documentation>
    <startEvent id="requestStart" name="Request Started"></startEvent>
    <subProcess id="userValidation" name="User Validation">
      <multiInstanceLoopCharacteristics isSequential="true" activiti:collection="validationUsers" activiti:elementVariable="user">
        <completionCondition>${approved=="false" || state=="CANCELLED"}</completionCondition>
      </multiInstanceLoopCharacteristics>
      <startEvent id="startevent1" name="Start"></startEvent>
      <userTask id="validateRequest" name="Validate Request" activiti:assignee="${user}">
        <extensionElements>
          <activiti:executionListener event="start" expression="#{validationListener.notifyExpression(execution)}"></activiti:executionListener>
          <activiti:executionListener event="end" expression="#{validationListener.notifyExpression(execution)}"></activiti:executionListener>
        </extensionElements>
      </userTask>
      <exclusiveGateway id="requestRejecedOrApproved" name="Request rejected or Approved check" default="flow15"></exclusiveGateway>
      <sequenceFlow id="validateRequestToGatewayFlow" sourceRef="validateRequest" targetRef="requestRejecedOrApproved"></sequenceFlow>
      <endEvent id="endevent1" name="End">
        <extensionElements>
          <activiti:executionListener event="start" expression="#{validationListener.setValidator(execution, user)}"></activiti:executionListener>
        </extensionElements>
      </endEvent>
      <endEvent id="endevent2" name="End">
        <extensionElements>
          <activiti:executionListener event="start" expression="#{validationListener.setRejecter(execution, user)}"></activiti:executionListener>
        </extensionElements>
      </endEvent>
      <endEvent id="endReminder" name="End"></endEvent>
      <sequenceFlow id="flow15" sourceRef="requestRejecedOrApproved" targetRef="endevent1"></sequenceFlow>
      <serviceTask id="sendNotificationMail" name="Send Notification Task" activiti:async="true" activiti:exclusive="false" activiti:expression="#{mailingDelegate.sendValidationMail(execution, validationMailId, user)}"></serviceTask>
      <sequenceFlow id="flow18" sourceRef="startevent1" targetRef="sendNotificationMail"></sequenceFlow>
      <sequenceFlow id="flow19" sourceRef="sendNotificationMail" targetRef="validateRequest"></sequenceFlow>
      <serviceTask id="servicetask1" name="Send Reminder Task" activiti:async="true" activiti:exclusive="false" activiti:expression="#{mailingDelegate.sendValidationMail(execution, validationMailId, user)}"></serviceTask>
      <sequenceFlow id="flow21" sourceRef="servicetask1" targetRef="endReminder"></sequenceFlow>
      <serviceTask id="servicetask2" name="Request rejected notification" activiti:async="true" activiti:exclusive="false" activiti:expression="#{mailingDelegate.sendRejectionMail(execution, rejectionMailId)}"></serviceTask>
      <sequenceFlow id="flow22" sourceRef="requestRejecedOrApproved" targetRef="servicetask2">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approved=="false" && state != "CANCELLED"}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flow23" sourceRef="servicetask2" targetRef="endevent2"></sequenceFlow>
      <serviceTask id="servicetask3" name="Send Cancellation Notification" activiti:expression="#{mailingDelegate.sendCancellationMail(execution, &quot;cancellationMail&quot;, user)}" activiti:resultVariableName="state"></serviceTask>
      <endEvent id="endevent3" name="End"></endEvent>
      <sequenceFlow id="flow25" sourceRef="servicetask3" targetRef="endevent3"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow4" sourceRef="requestStart" targetRef="userValidation"></sequenceFlow>
    <endEvent id="endProcess" name="End"></endEvent>
    <sequenceFlow id="flow11" sourceRef="userValidation" targetRef="endProcess"></sequenceFlow>
    <boundaryEvent id="reminderTimer" name="Reminder Timer" attachedToRef="userValidation" cancelActivity="false">
      <timerEventDefinition>
        <timeCycle>R/P7D</timeCycle>
      </timerEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow20" sourceRef="reminderTimer" targetRef="servicetask1"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="userValidation" cancelActivity="true">
      <signalEventDefinition signalRef="cancelRequest"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow24" sourceRef="boundarysignal1" targetRef="servicetask3"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_genericRequest">
    <bpmndi:BPMNPlane bpmnElement="genericRequest" id="BPMNPlane_genericRequest">
      <bpmndi:BPMNShape bpmnElement="requestStart" id="BPMNShape_requestStart">
        <omgdc:Bounds height="35.0" width="35.0" x="434.0" y="23.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="userValidation" id="BPMNShape_userValidation">
        <omgdc:Bounds height="571.0" width="541.0" x="181.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="361.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="validateRequest" id="BPMNShape_validateRequest">
        <omgdc:Bounds height="55.0" width="105.0" x="326.0" y="322.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="requestRejecedOrApproved" id="BPMNShape_requestRejecedOrApproved">
        <omgdc:Bounds height="40.0" width="40.0" x="358.0" y="447.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="460.0" y="450.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="246.0" y="520.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endReminder" id="BPMNShape_endReminder">
        <omgdc:Bounds height="35.0" width="35.0" x="225.0" y="560.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sendNotificationMail" id="BPMNShape_sendNotificationMail">
        <omgdc:Bounds height="55.0" width="105.0" x="326.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="190.0" y="610.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="211.0" y="440.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55.0" width="105.0" x="494.0" y="610.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="529.0" y="540.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reminderTimer" id="BPMNShape_reminderTimer">
        <omgdc:Bounds height="30.0" width="30.0" x="228.0" y="690.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarysignal1" id="BPMNShape_boundarysignal1">
        <omgdc:Bounds height="30.0" width="30.0" x="628.0" y="690.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endProcess" id="BPMNShape_endProcess">
        <omgdc:Bounds height="35.0" width="35.0" x="427.0" y="760.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="validateRequestToGatewayFlow" id="BPMNEdge_validateRequestToGatewayFlow">
        <omgdi:waypoint x="378.0" y="377.0"></omgdi:waypoint>
        <omgdi:waypoint x="378.0" y="447.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="398.0" y="467.0"></omgdi:waypoint>
        <omgdi:waypoint x="460.0" y="467.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="378.0" y="205.0"></omgdi:waypoint>
        <omgdi:waypoint x="378.0" y="240.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow19" id="BPMNEdge_flow19">
        <omgdi:waypoint x="378.0" y="295.0"></omgdi:waypoint>
        <omgdi:waypoint x="378.0" y="322.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow21" id="BPMNEdge_flow21">
        <omgdi:waypoint x="242.0" y="610.0"></omgdi:waypoint>
        <omgdi:waypoint x="242.0" y="595.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow22" id="BPMNEdge_flow22">
        <omgdi:waypoint x="358.0" y="467.0"></omgdi:waypoint>
        <omgdi:waypoint x="316.0" y="467.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow23" id="BPMNEdge_flow23">
        <omgdi:waypoint x="263.0" y="495.0"></omgdi:waypoint>
        <omgdi:waypoint x="263.0" y="520.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow25" id="BPMNEdge_flow25">
        <omgdi:waypoint x="546.0" y="610.0"></omgdi:waypoint>
        <omgdi:waypoint x="546.0" y="575.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="451.0" y="58.0"></omgdi:waypoint>
        <omgdi:waypoint x="451.0" y="150.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="451.0" y="721.0"></omgdi:waypoint>
        <omgdi:waypoint x="444.0" y="760.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow20" id="BPMNEdge_flow20">
        <omgdi:waypoint x="243.0" y="690.0"></omgdi:waypoint>
        <omgdi:waypoint x="242.0" y="665.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow24" id="BPMNEdge_flow24">
        <omgdi:waypoint x="643.0" y="690.0"></omgdi:waypoint>
        <omgdi:waypoint x="642.0" y="638.0"></omgdi:waypoint>
        <omgdi:waypoint x="599.0" y="637.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
12 REPLIES 12

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I tried to deploy your process definition in jUnit test.
I've got following exception:

org.activiti.engine.ActivitiException: Errors while parsing:
[Validation set: 'activiti-executable-process' | Problem: 'activiti-seq-flow-invalid-target'] : Invalid target for sequenceflow, the target isn't defined in the same scope as the source - [Extra info : processDefinitionId = genericRequest | processDefinitionName = genericRequest |  | id = flow20 | ] ( line: 90, column: 82)
[Validation set: 'activiti-executable-process' | Problem: 'activiti-seq-flow-invalid-target'] : Invalid target for sequenceflow, the target isn't defined in the same scope as the source - [Extra info : processDefinitionId = genericRequest | processDefinitionName = genericRequest |  | id = flow24 | ] ( line: 94, column: 84)

description is self-explanatory.
Regards
Martin

mapor
Champ in-the-making
Champ in-the-making
Well, it's what i said right in the title of the post.

The fact is :

- That XML is generated by Eclipse
- That XML worked with the 5.15.1 of activiti
- When i put the piece of XML in the subprocess tag to be in the same scope (from what i think to be the "scope" here) i got a NPE from FlowNodeHistoryParseHandler

This is the graphical model of my workflow, i highlight in red the two flow that throw me the error.

[img]http://2imgs.com/2i/t/0420a78d5e.jpg[/img]

I don't think i'm doing anything wrong here since that worked before upgrading to 5.16.
It seems that in the 5.15 the validation was disabled, so maybe there is a problem between how the XML is validating by the processValidator and how is he then handled after.

So i'm searching :
1- How to disable validation fast to be able to work on my workflows, this one is called by all the others as a call activiti, so i'm stuck if i can't deploy it
2- Resolve the problem

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

2- Resolve the problem

The problem is that boundary events associated to the subprocess have flows which connect them to the service tasks defined in the subprocess. One possibility is to make copy of servicetask1 and servicetask3 in the "main" process and reference these new copies from boundary events

      <serviceTask id="servicetask11" name="Send Reminder Task" activiti:async="true" activiti:exclusive="false"
                   activiti:expression="#{mailingDelegate.sendValidationMail(execution, validationMailId, user)}"></serviceTask>
      <serviceTask id="servicetask13" name="Send Cancellation Notification"
                   activiti:expression="#{mailingDelegate.sendCancellationMail(execution, &quot;cancellationMail&quot;, user)}"
                   activiti:resultVariableName="state"></serviceTask>
    </subProcess>
    <serviceTask id="servicetask1" name="Send Reminder Task" activiti:async="true" activiti:exclusive="false"
                 activiti:expression="#{mailingDelegate.sendValidationMail(execution, validationMailId, user)}"></serviceTask>
    <serviceTask id="servicetask3" name="Send Cancellation Notification"
                 activiti:expression="#{mailingDelegate.sendCancellationMail(execution, &quot;cancellationMail&quot;, user)}"
                 activiti:resultVariableName="state"></serviceTask>

jUnit test with deployed process
https://github.com/martin-grofcik/activiti-unit-test-template/tree/forum-support-error-workflows-tar...

Regards
Martin

mapor
Champ in-the-making
Champ in-the-making
Well activiti deploy succesfully the workflow, but when i try to use it :
org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'user' when i use the cancellation procedure (signal "cancelRequest" send to the execution).

Of course he doesn't find that variable since it's defined within the subprocess as the loop variable.

This workflow works perfectly (meaning deployment and full execution) against activiti 5.15.1 (just tested it again this morning) An if i remember well, process validation was disabled.

The bug is against activiti 5.16 validation the flow are linking boundary events define at the same level as the subprocess. This is what is expected if we refer to the user guide : " A reference to the activity to which the event is attached through the attachedToRef attribute. Note that a boundary event is defined on the same level as the activities to which they are attached (i.e. no inclusion of the boundary event inside the activity). ".

But if i want to use variable in the subprocess i have to link the flow between those boundaries event and task within the subprocess, and since there aren't in the same scope, validation will fail.

So :
- Validation should authorize flows to links boundaryevent to a task defined in a subprocess since activiti handle it perfectly when executing the workflow.
- The fact that boundary event are define in the same level as the elements is a design problem when comes to attached it to a sub process.
- Boudary events aren't designed to be attached to subprocess while accessing to the variable of this subprocess and then it's my mistake but it still work against the version 5.15.1 and that would be quite a pity…

mapor
Champ in-the-making
Champ in-the-making
Hi,

A little update to say that i found a work around for me : i attached the boundaries event to the user's task.
That works for me since there is no reason that i should use the boundary events on my whole subprocess.

But i would like to know, if ever it can be usefull one day :
- Does boundary events are designed to use internal variables of subprocesses when attached to the subprocess ?
- For subprocess that are loops : how does a boundary timer works ? is it reset for each loop or not ?

jbarrez
Star Contributor
Star Contributor
Indeed, in 5.16 we enhanced validation to be more correct. It's indeed not good that the Eclipse designer allows to generate it, it shouldn't.

Boundary events are not allowed to go into the scope. Even more, sequence flow in general cannot cross scopes like this at all in bpmn2.0.

You should be able to access variables that are used within the subprocess (unless you are using setVariableLocal)
So which variable are you trying to access? Why cant you have a boundary event that goes to a task outside of the subprocess?

mapor
Champ in-the-making
Champ in-the-making
My subprocess is a multiinstanceprocess, i'm trying to access to the variable that contains the current value of the list (user).

In fact, in order to display the current validator, i have to set manually a variable next = user, because that process is only used as a call activiti from other processes.

And even with that, i have to get that variable by merging all variables of the process and all subprocesses generated the workflow to get that value.

This is my first project with activiti and i'm not really used to BPMN, so i have some problem between BPMN design, activiti's API (only Java, i used it within my application, not the Rest API). My Workflow's service try to do with that.

Another thing that give me some trouble : get current task assign to a user for a given type of process. I have to set a variable within the call activiti of validation to get the task in one request.

<java>
List<Task> list = taskService.createTaskQuery().taskAssignee(id).processVariableValueEquals("origin",processKey).list();
</java>

<code>
So which variable are you trying to access? Why cant you have a boundary event that goes to a task outside of the subprocess?
</code>

Well if i can access to that variable outside the subprocess, i won't have anymore problem to put that task outside the subprocess but when i saw that eclipse place the boundary inside the subprocess (in the graphical representation i mean) i thought that it was more logical to put the task in the subprocess too, even without considering the scope variable problem.

mapor
Champ in-the-making
Champ in-the-making
Any news  about that ?

trademak
Star Contributor
Star Contributor
What's the news you are expecting? With an embedded sub process you can access all variables in the process instance scope and vice versa. So the task should be outside the sub process. You shouldn't draw sequence flows from a boundary event on a sub process, back into the sub process. That's not valid BPMN.

Best regards,