flowable/flowable-engine · error · FlowableIllegalArgumentException

Cannot combine scopeType(String) with onlyCmmn() in the…

Error message

Cannot combine scopeType(String) with onlyCmmn() in the same query

What it means

ExternalWorkerJobAcquireBuilderImpl.onlyCmmn() rejects calls when an explicit scopeType(String) was already set on the builder, since onlyCmmn() is a shortcut for scopeType(CMMN). Flowable throws FlowableIllegalArgumentException to prevent conflicting scope values.

Solutions

  1. Pick either scopeType(String) or the convenience methods, not both
  2. Validate the builder call sequence in shared helper code
  3. Reset the builder when changing scope strategy

Example fix

// before
builder.scopeType("bpmn").onlyCmmn();
// after
builder.scopeType("bpmn");
Defensive patterns

Strategy: validation

Validate before calling

if (scopeTypeFromConfig != null && useOnlyCmmnShortcut) throw new IllegalArgumentException("cannot combine scopeType() with onlyCmmn()");

Try / catch

try { builder.onlyCmmn(); } catch (FlowableIllegalArgumentException e) { if (!e.getMessage().contains("Cannot combine")) throw e; /* switch to scopeType(String) only */ }

Prevention

When it happens

Trigger: Calling builder.scopeType("bpmn") (or any non-null scopeType) followed by onlyCmmn().

Common situations: Mixing dynamic scopeType from configuration with static convenience methods.

Related errors


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

Appendix: source

Thrown at modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/ExternalWorkerJobAcquireBuilderImpl.java:83

    public ExternalWorkerJobAcquireBuilder onlyBpmn() {
        if (ScopeTypes.CMMN.equals(scopeType)) {
            throw new FlowableIllegalArgumentException("Cannot combine onlyCmmn() with onlyBpmn() in the same query");
        }

        if (scopeType != null) {
            throw new FlowableIllegalArgumentException("Cannot combine scopeType(String) with onlyBpmn() in the same query");
        }
        return scopeType(ScopeTypes.BPMN);
    }

    @Override
    public ExternalWorkerJobAcquireBuilder onlyCmmn() {
        if (ScopeTypes.BPMN.equals(scopeType)) {
            throw new FlowableIllegalArgumentException("Cannot combine onlyBpmn() with onlyCmmn() in the same query");
        }

        if (scopeType != null) {
            throw new FlowableIllegalArgumentException("Cannot combine scopeType(String) with onlyCmmn() in the same query");
        }
        return scopeType(ScopeTypes.CMMN);
    }

    @Override
    public ExternalWorkerJobAcquireBuilder scopeType(String scopeType) {
        this.scopeType = scopeType;
        return this;
    }

    @Override
    public ExternalWorkerJobAcquireBuilder tenantId(String tenantId) {
        this.tenantId = tenantId;
        return this;
    }

    @Override
    public ExternalWorkerJobAcquireBuilder forUserOrGroups(String userId, Collection<String> groups) {

View on GitHub (pinned to d6d39ce1c6)