Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

cancel
Showing results for 
Search instead for 
Did you mean: 
nhhao1996
Active Member II

Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

Hi everyone!

I just made a simple process: start -> service task -> end

I create a Java class to implement into service task to save diagram before process end. Here is my code:

public class CaptureProcess implements JavaDelegate{

@Override
   public void execute(DelegateExecution delegateExecution) throws Exception {

      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

      RepositoryService repositoryService = processEngine.getRepositoryService();

      ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                                                                     .processDefinitionKey("parentProcess")
                                                                      .singleResult();

      String diagramResourceName = processDefinition.getDiagramResourceName();

      InputStream imageStream = repositoryService.getResourceAsStream(
      processDefinition.getDeploymentId(), diagramResourceName);

      FileOutputStream outstream = new FileOutputStream(new File("download-image.png"));

      IOUtils.copy(imageStream, outstream);
      outstream.close();
   }
}

I copied jar file when create deployment artifact to my activiti-explorer path, but when I deploy bar file and run, it's appear warning: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail.

Can you tell my what's wrong with my code?

1 Solution

Accepted Solutions
nhhao1996
Active Member II

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

Because process definition is just get the designed diagram not diagram with current task highlighted so I changed it into process instance, here is my code to get diagram with current task with process instance:

public class CaptureProcess implements JavaDelegate {

      @Override
      public void execute(DelegateExecution execution) throws Exception {
            FileOutputStream outputStream = new FileOutputStream(new File("d:\\service-task.png"));

            IOUtils.copy(captureProcess(execution.getProcessInstanceId()), outputStream);
            outputStream.close();
      }

      public static InputStream captureProcess(String processInstanceId) throws IOException {
            ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

            RuntimeService runtimeService = processEngine.getRuntimeService();

            RepositoryService repositoryService = processEngine.getRepositoryService();

            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                                                                     .processInstanceId(processInstanceId).singleResult();

            // null check
            if (processInstance != null) {
                  // get process model
                  BpmnModel model = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());

                  if (model != null && model.getLocationMap().size() > 0) {
                        ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
                        return generator.generateDiagram(model, "png" ,runtimeService.getActiveActivityIds(processInstanceId));
                  }
         }
         return null;
      }
}

And if you want to get original diagram without highlighted task, you can check in Activiti User Guilde, there are a example code for you to do this:

ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .

                                                                        processDefinitionKey("expense") .singleResult();

String diagramResourceName = processDefinition.getDiagramResourceName();

InputStream imageStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), diagramResourceName);

View solution in original post

5 Replies
pault
Active Member II

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

Do you have the full stack trace for the exception to help see what is going on.

nhhao1996
Active Member II

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

I fixed! Thank you!

kgastaldo
Senior Member

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

Could you share how you fixed the issue? Just in case someone else runs into the same issue!

nhhao1996
Active Member II

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

Because process definition is just get the designed diagram not diagram with current task highlighted so I changed it into process instance, here is my code to get diagram with current task with process instance:

public class CaptureProcess implements JavaDelegate {

      @Override
      public void execute(DelegateExecution execution) throws Exception {
            FileOutputStream outputStream = new FileOutputStream(new File("d:\\service-task.png"));

            IOUtils.copy(captureProcess(execution.getProcessInstanceId()), outputStream);
            outputStream.close();
      }

      public static InputStream captureProcess(String processInstanceId) throws IOException {
            ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

            RuntimeService runtimeService = processEngine.getRuntimeService();

            RepositoryService repositoryService = processEngine.getRepositoryService();

            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                                                                     .processInstanceId(processInstanceId).singleResult();

            // null check
            if (processInstance != null) {
                  // get process model
                  BpmnModel model = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());

                  if (model != null && model.getLocationMap().size() > 0) {
                        ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
                        return generator.generateDiagram(model, "png" ,runtimeService.getActiveActivityIds(processInstanceId));
                  }
         }
         return null;
      }
}

And if you want to get original diagram without highlighted task, you can check in Activiti User Guilde, there are a example code for you to do this:

ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .

                                                                        processDefinitionKey("expense") .singleResult();

String diagramResourceName = processDefinition.getDiagramResourceName();

InputStream imageStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), diagramResourceName);

nhhao1996
Active Member II

Re: Invocation of method componentEvent in org.activiti.explorer.ui.task.TaskDetailPanel$4 fail

Jump to solution

I updated the answer, thanks for your reply!