Unable to get case instance diagram

I have configured a case model with an association between two tasks (please find the attached case model diagram for ref).

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/cmmn" xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI" xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC" xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI" targetNamespace="tns">
  <case id="caseModel" name="caseModel" flowable:initiatorVariableName="initiator">
    <casePlanModel id="model1" name="model1" flowable:formFieldValidation="true">
      <planItem id="planItem3" name="stage1" definitionRef="stage1"></planItem>
      <stage id="stage1" name="stage1">
        <planItem id="planItem1" name="task1" definitionRef="task1"></planItem>
        <planItem id="planItem2" name="task2" definitionRef="task2"></planItem>
        <humanTask id="task1" name="task1" flowable:assignee="${initiator}" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:flowable-idm-initiator xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:flowable-idm-initiator>
          </extensionElements>
        </humanTask>
        <humanTask id="task2" name="task2" flowable:assignee="${initiator}" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:flowable-idm-initiator xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:flowable-idm-initiator>
          </extensionElements>
        </humanTask>
      </stage>
    </casePlanModel>
  </case>
  <cmmndi:CMMNDI>
    <cmmndi:CMMNDiagram id="CMMNDiagram_caseModel">
      <cmmndi:CMMNShape id="CMMNShape_model1" cmmnElementRef="model1">
        <dc:Bounds height="261.0" width="580.0" x="45.0" y="75.0"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem3" cmmnElementRef="planItem3">
        <dc:Bounds height="170.0" width="370.0" x="120.0" y="120.5"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem1" cmmnElementRef="planItem1">
        <dc:Bounds height="80.0" width="100.0" x="177.60000000000002" y="162.5"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem2" cmmnElementRef="planItem2">
        <dc:Bounds height="80.0" width="100.0" x="342.6" y="162.5"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNEdge id="CMMNEdge_sid-6D399236-476D-493F-AE2D-B7BD73836C7F" cmmnElementRef="task1" targetCMMNElementRef="task2">
        <di:waypoint x="277.54999999988974" y="202.5"></di:waypoint>
        <di:waypoint x="342.5999999999847" y="202.5"></di:waypoint>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNEdge>
    </cmmndi:CMMNDiagram>
  </cmmndi:CMMNDI>
</definitions>

Using this case model I am able to deploy and crate case instance, And able to get the tasks. But When I try to get the case instance diagram using case instance diagram rest API I am getting “500 internal server error”.

While looking into the code change in drawAssociation() method in DefaultCaseDiagramGenerator.java

    String sourceRef = association.getSourceRef();
    ...
    sourceElement = cmmnModel.findPlanItem(sourceRef);

Here we unable to find planItem using sourceRef. We need to pass the planItemId of the task (planItem1) but we are providing task Id like (task1) for the association. Here we unable to get planItem and getting sourceElement as null causing Null pointer exception in cmmnModel.getGraphicInfo(sourceElement.getId()).

That looks correct. Are you willing to do a PR, as you already did all the hard work figuring it out :slight_smile:

Also, what’s your use case of using an association?

Thank you @joram for your reply.

Here, Our use case is to completion of ‘task1’ I want to trigger ‘task2’ without any condition. Is the configured model right? If no, What is the behaviour of the configured model?

If you want to model that, you’d need an entry sentry on task2, and connect that sentry to task1. The event to listen to would be ‘complete’ (but that’s the default, so nothing to configure there).

Thank you @joram,

In that case, What is the behaviour of the configured model (i.e association between two tasks without any sentries)? Or is it a wrong way of designing a model that we shouldn’t design like this.

Indeed. Associations need to have a sentry to have behaviour. Associations without anything else are informative only.