flowable/flowable-engine · warning · ActivitiObjectNotFoundException

Comment with id ' ' doesn't exists.

Error message

Comment with id '${commentId}' doesn't exists.

What it means

DeleteCommentCmd deletes a single comment by id, and throws ActivitiObjectNotFoundException with Comment.class when findComment returns null. The id is syntactically fine but no comment row with it exists.

Solutions

  1. Verify the comment exists (taskService.getTaskComments / getProcessInstanceComments) before deleting
  2. Handle the missing comment as a no-op: catch ActivitiObjectNotFoundException and log
  3. Correct the commentId source (refresh from the server instead of a cached list)

Example fix

// before
taskService.deleteComment(commentId);
// after
try {
    taskService.deleteComment(commentId);
} catch (ActivitiObjectNotFoundException e) {
    // comment already gone; treat as deleted
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = taskService.getProcessInstanceComments(procInstId).stream().anyMatch(c -> c.getId().equals(commentId));

Try / catch

try { taskService.deleteComment(commentId); } catch (ActivitiObjectNotFoundException e) { /* already deleted — treat as success */ }

Prevention

When it happens

Trigger: taskService.deleteComment(commentId) (or the cmd directly) with an id already deleted, never created, or from another database.

Common situations: Double-delete in a UI (comment removed by another user first); stale client cache listing comments; wrong-environment ids in test scripts.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/80e7e6ba0dfdd42b. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteCommentCmd.java:49

    protected String taskId;
    protected String processInstanceId;
    protected String commentId;

    public DeleteCommentCmd(String taskId, String processInstanceId, String commentId) {
        this.taskId = taskId;
        this.processInstanceId = processInstanceId;
        this.commentId = commentId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        CommentEntityManager commentManager = commandContext.getCommentEntityManager();

        if (commentId != null) {
            // Delete for an individual comment
            Comment comment = commentManager.findComment(commentId);
            if (comment == null) {
                throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
            }
            commentManager.delete((CommentEntity) comment);

        } else {
            // Delete all comments on a task of process
            ArrayList<Comment> comments = new ArrayList<>();
            if (processInstanceId != null) {
                comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
            }
            if (taskId != null) {
                comments.addAll(commentManager.findCommentsByTaskId(taskId));
            }

            for (Comment comment : comments) {
                commentManager.delete((CommentEntity) comment);
            }
        }
        return null;

View on GitHub (pinned to d6d39ce1c6)