flowable/flowable-engine · error · FlowableIllegalArgumentException

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

Error message

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

What it means

ExternalWorkerJobAcquireBuilderImpl.onlyBpmn() rejects calls when an explicit scopeType(String) was already set, because onlyBpmn() is just a shortcut for scopeType(BPMN) and combining them directly conflicts. Flowable throws FlowableIllegalArgumentException.

Solutions

  1. Use only scopeType(String) when the scope is dynamic
  2. Use only onlyBpmn()/onlyCmmn() when the scope is static
  3. Choose one mechanism per builder instance

Example fix

// before
builder.scopeType(cfgScope).onlyBpmn();
// after
builder.scopeType(cfgScope);
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Calling builder.scopeType("cmmn") (or any non-null scopeType) and then onlyBpmn() on the same builder.

Common situations: Mixing the convenience methods with the generic scopeType() when scope type comes from configuration.

Related errors


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

Appendix: source

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

        }

        if (lockDuration == null) {
            throw new FlowableIllegalArgumentException("lockDuration is null");
        }

        this.topic = topic;
        this.lockDuration = lockDuration;
        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) {

View on GitHub (pinned to d6d39ce1c6)