Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-9552

Create Attachment fails when providing no taskId but processInstanceId

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: L3 - Default
    • Resolution: Fixed
    • Affects Version/s: 7.9.5, 7.8.12, 7.10.0-alpha5
    • Fix Version/s: 7.11.0, 7.9.10, 7.10.3, 7.11.0-alpha2
    • Component/s: None
    • Labels:

      Description

      Scenario:
      Multiple executions exist during the attachment creation for a process instance.

      Example API call:

      TaskService taskService = processEngine.getTaskService();
      taskService.createAttachment(uploadContentType, null, processInstanceId, uploadFileName, description, fileInputStream);
      

      Current behavior:
      An exception is thrown:

      org.camunda.bpm.engine.ProcessEngineException: processInstances does not have 1 elements
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_181]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_181]
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_181]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_181]
      	at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:344) ~[camunda-engine-7.8.0.jar:7.8.0]
      	at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNumberOfElements(EnsureUtil.java:311) ~[camunda-engine-7.8.0.jar:7.8.0]
      	at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNumberOfElements(EnsureUtil.java:299) ~[camunda-engine-7.8.0.jar:7.8.0]
      	at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNumberOfElements(EnsureUtil.java:294) ~[camunda-engine-7.8.0.jar:7.8.0]
      	at org.camunda.bpm.engine.impl.cmd.CreateAttachmentCmd.execute(CreateAttachmentCmd.java:74) ~[camunda-engine-7.8.0.jar:7.8.0]
      	at org.camunda.bpm.engine.impl.cmd.CreateAttachmentCmd.execute(CreateAttachmentCmd.java:43) ~[camunda-engine-7.8.0.jar:7.8.0]
      

      Expected behavior:
      The attachment is created successfully.

      Hints: The exception is caused by the class CreateAttachmentCMD

      A workaround is to provide an empty String instead of null as taskId but then the operationLogManager is never called (the task of the taskId is never validated).

        Issue Links

          Activity

          Hide
          yana.vasileva Yana Vasileva added a comment -

          Questions from Thomas Weber:
          So the main question is: Why is the number of executions checked (when providing an processInstance only) and is this the suggested way to create an attachment relating to a process instance?

          Show
          yana.vasileva Yana Vasileva added a comment - Questions from Thomas Weber : So the main question is: Why is the number of executions checked (when providing an processInstance only) and is this the suggested way to create an attachment relating to a process instance?
          Hide
          yana.vasileva Yana Vasileva added a comment - - edited

          Hi Thomas Weber,

          I can confirm that it is a bug and this is the way at the moment to create an attachment related to a process instance.

          Show
          yana.vasileva Yana Vasileva added a comment - - edited Hi Thomas Weber , I can confirm that it is a bug and this is the way at the moment to create an attachment related to a process instance.

            People

            • Assignee:
              Unassigned
              Reporter:
              webert Thomas Weber
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development