The error is not coming because you are getting the execution listeners. It is coming because you are using an internal API ProcessDefinitionUtil outside of a command context.
The correct way to do this is to use the RepositoryService.
e.g.
Process process = repositoryService.getBpmnModel(definitionId).getMainProcess()
or
Process process = repositoryService.getBpmnModel(definitionId).getProcess(processDefinitionKey)
Hi @filiphr ,
Thanks for your response.
Yes, I’m able to get the process details with the code that you have shared but I don’t get the information from process that I was looking for.
I will try to briefly explain my use case.
User wants to be notified if a process is canceled and he wants a screen where he can configure related fields as well. Something like this
There is an option to use the Event Listeners field in the stencil with id BPMNDiagram. But for now, I am using Execution Listenersend event since the user also wants a configurable screen like above.
So, when a user tries to cancel the process, I get the execution listener details from the Process, trigger cancel notification and set an empty arraylist in its executionListeners field. Also, I set an empty ArrayList to executionListeners field of Process when a process is completed, so that cancel notification is not sent when a process is completed. I do this when PROCESS_COMPLETED is dispatched.
The logic that you have shared fetches me the details if the process instance is not completed. But for a completed process instance, I get an empty list there.
I’m assuming the reason is that I cleared executionListeners field in PROCESS_COMPLETED event.
To meet this, as of now I’m extracting execution listeners from modelEditorJson using modelRepository.findByKeyAndType().get(0).getModelEditorJson();
Is there a better way to do this?