Activiti/Activiti · error · ActivitiObjectNotFoundException

No deployment found for id =

Error message

No deployment found for id = '${deploymentId}'

What it means

After validating the id is non-null, SetDeploymentCategoryCmd looks up the deployment via DeploymentEntityManager.findById. If no deployment row exists for the given id, Activiti throws ActivitiObjectNotFoundException with the message 'No deployment found for id = ...'.

Solutions

  1. Verify the deploymentId exists: repositoryService.createDeploymentQuery().deploymentId(id).singleResult() != null before calling setDeploymentCategory.
  2. List valid ids with createDeploymentQuery().list() and use one of those.
  3. Confirm the engine is connected to the database/environment where the deployment was made.

Example fix

// before
repositoryService.setDeploymentCategory(deploymentId, "production");
// after
Deployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (d != null) {
  repositoryService.setDeploymentCategory(deploymentId, "production");
}
Defensive patterns

Strategy: validation

Validate before calling

Deployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (d == null) {
  throw new IllegalStateException("Deployment " + deploymentId + " does not exist");
}

Try / catch

try {
  repositoryService.setDeploymentCategory(deploymentId, category);
} catch (ActivitiObjectNotFoundException e) {
  if (Deployment.class.equals(e.getObjectClass())) {
    // fall back: list valid deployments or notify caller the id is stale
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling RepositoryService.setDeploymentCategory(id, category) with an id that does not exist in ACT_RE_DEPLOYMENT (deleted deployment, typo, id from another database/environment).

Common situations: Referencing a deployment deleted by deleteDeployment, pointing a test at a different DB schema, stale cached ids after a re-deployment, or copying ids across environments.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/SetDeploymentCategoryCmd.java:48

public class SetDeploymentCategoryCmd implements Command<Void> {

    protected String deploymentId;
    protected String category;

    public SetDeploymentCategoryCmd(String deploymentId, String category) {
        this.deploymentId = deploymentId;
        this.category = category;
    }

    public Void execute(CommandContext commandContext) {
        if (deploymentId == null) {
            throw new ActivitiIllegalArgumentException("Deployment id is null");
        }

        DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId);

        if (deployment == null) {
            throw new ActivitiObjectNotFoundException(
                "No deployment found for id = '" + deploymentId + "'",
                Deployment.class
            );
        }

        executeInternal(commandContext, deployment);
        return null;
    }

    protected void executeInternal(CommandContext commandContext, DeploymentEntity deployment) {
        // Update category
        deployment.setCategory(category);

        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            commandContext
                .getProcessEngineConfiguration()
                .getEventDispatcher()
                .dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment));

View on GitHub (pinned to 56435b1a97)