Activiti/Activiti · error · ActivitiException

In order to use comments, history should be enabled

Error message

In order to use comments, history should be enabled

What it means

Activiti stores comments and events as history entities, so comment operations require history to be enabled. CommentEntityManagerImpl.checkHistoryEnabled throws this ActivitiException when the history manager reports history disabled (history level 'none'). The engine refuses the operation because there is nowhere to persist comments.

Solutions

  1. Enable history in config: set historyLevel to activity/audit (setHistoryLevel(HistoryLevel.ACTIVITY) or <property name="historyLevel" value="audit"/>).
  2. Redeploy/restart the engine with the corrected configuration.
  3. If history must remain disabled, replace Activiti comments with an application-level comment store.
  4. Gate comment code on processEngineConfiguration.getHistoryLevel() != HistoryLevel.NONE.

Example fix

// before
<property name="historyLevel" value="none"/>
// after
<property name="historyLevel" value="audit"/>
Defensive patterns

Strategy: validation

Validate before calling

if (processEngineConfig.getHistoryLevel() == org.activiti.engine.impl.history.HistoryLevel.NONE) {
    throw new IllegalStateException("Comments require history to be enabled");
}

Try / catch

try {
    taskService.addComment(taskId, procInstId, message);
} catch (org.activiti.engine.ActivitiException e) {
    if (e.getMessage().contains("history should be enabled")) {
        throw new MisconfiguredEngineException("Enable history to use comments", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling taskService.addComment(...), getTaskComments, getProcessInstanceComments, or event lookup methods while the engine's historyLevel is none (config uses HistoryLevel.NONE or xml value 'none').

Common situations: Engines tuned with history disabled for performance; same codebase deployed to an environment whose activiti.cfg.xml differs; upgrade where history config was dropped; new feature using comments added to a history-free setup.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/167776d39248c22e. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CommentEntityManagerImpl.java:187

                if (process != null) {
                    processDefinitionId = process.getProcessDefinitionId();
                }
            }
            getEventDispatcher().dispatchEvent(
                ActivitiEventBuilder.createEntityEvent(
                    ActivitiEventType.ENTITY_DELETED,
                    commentEntity,
                    processInstanceId,
                    processInstanceId,
                    processDefinitionId
                )
            );
        }
    }

    protected void checkHistoryEnabled() {
        if (!getHistoryManager().isHistoryEnabled()) {
            throw new ActivitiException("In order to use comments, history should be enabled");
        }
    }

    public CommentDataManager getCommentDataManager() {
        return commentDataManager;
    }

    public void setCommentDataManager(CommentDataManager commentDataManager) {
        this.commentDataManager = commentDataManager;
    }
}

View on GitHub (pinned to 56435b1a97)