flowable/flowable-engine · error · FlowableIllegalArgumentException

Cannot combine onlyBpmn() with onlyCmmn() in the same query

Error message

Cannot combine onlyBpmn() with onlyCmmn() in the same query

What it means

ExternalWorkerJobAcquireBuilderImpl.onlyCmmn() restricts acquisition to CMMN jobs. If scopeType is already BPMN (onlyBpmn() called first), combining both is ambiguous and Flowable throws FlowableIllegalArgumentException.

Solutions

  1. Call only one of onlyBpmn()/onlyCmmn() per builder
  2. Guard the chaining with if/else on the intended scope
  3. Recreate the builder for a different scope

Example fix

// before
builder.onlyBpmn().onlyCmmn();
// after
if (cmmn) { builder.onlyCmmn(); } else { builder.onlyBpmn(); }
Defensive patterns

Strategy: validation

Validate before calling

if (useBpmn && useCmmn) throw new IllegalArgumentException("onlyBpmn and onlyCmmn are mutually exclusive");

Try / catch

try { builder.onlyCmmn(); } catch (FlowableIllegalArgumentException e) { if (!e.getMessage().contains("Cannot combine")) throw e; /* resolve conflicting scope flags */ }

Prevention

When it happens

Trigger: Calling onlyBpmn() then onlyCmmn() on the same acquire builder.

Common situations: Chain built programmatically with both flags set from boolean conditions that were both true.

Related errors


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

Appendix: source

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

        return this;
    }

    @Override
    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;

View on GitHub (pinned to d6d39ce1c6)