Getting error while cleanup historical data

below is the the implemeation :slight_smile:

public void execute(DelegateExecution delegateExecution) throws Exception {
      System.out.println("--->"+ "deleting...");
    try {
    } catch (RuntimeException e) {
        throw new BpmnError("cleanupException", "Message: " + e.getMessage() + ", Stacktrace: " + e.getStackTrace());

private void deleteUnusedDeployments(DelegateExecution delegateExecution) {
    List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
    System.out.println("--->"+ deployments.get(0));

    for (Deployment deployment : deployments) {
        boolean deploymentCanBeDeleted = true;

        List<ProcessDefinition> processDefinitions = repositoryService
        System.out.println("--->"+  repositoryService
        for (ProcessDefinition processDefinition : processDefinitions) {
            ProcessDefinition latestProcessDefiniton = repositoryService
            boolean isLatest = latestProcessDefiniton.getId().equals(processDefinition.getId());
            boolean hasRunningInstances = runtimeService
                    .processDefinitionId(processDefinition.getId()).count() > 0;
            boolean hasHistoricInstances = historyService
                    .processDefinitionId(processDefinition.getId()).count() > 0;
            if (isLatest || hasRunningInstances || hasHistoricInstances) {
                deploymentCanBeDeleted = false;
        if (deploymentCanBeDeleted) {
            System.out.println("deleted tem successfully");




Below Error getting:
2021-10-11 21:48:20.714 INFO 29836 — [aTaskExecutor-1] org.camunda.bpm.engine.bpmn.behavior : ENGINE-02001 Execution with id ‘say-hello’ throws an error event with errorCode ‘cleanupException’, but no catching boundary event was defined. Execution is ended (none end event semantics).

Hi @Shashi_Bhushan,

I can’t see the root-cause, but be careful with BpmnErrors, see

 * Special exception that can be used to throw a BPMN Error from
 * {@link JavaDelegate}s and expressions.
 * This should only be used for business faults, which shall be handled by a
 * Boundary Error Event or Error Event Sub-Process modeled in the process
 * definition. Technical errors should be represented by other exception types.

So, if you don’t have any catching boundary event defined as part of your process-model, all process-instances will end without any remaining part in case of error.

BR rnschk :slight_smile:


Thanks @rnschk ! got resolved…

1 Like