flowable/flowable-engine · error · FlowableException

The service '' is not available in the current context…

Error message

The service '' is not available in the current context. Please enable services in scripting.

What it means

FlowableException thrown by VariableScopeResolver.get when a script reads a bean named after an engine service (e.g. 'runtimeService', 'taskService') while servicesEnabledInScripting is disabled in the process engine configuration. Flowable blocks service access from scripts by default for safety.

Solutions

  1. Set processEngineConfiguration.setServicesEnabledInScripting(true) if service access from scripts is intended.
  2. Prefer passing required data as process variables before script execution instead of calling services from scripts.
  3. Move service calls into a JavaDelegate or task listener (Java code), keeping the script pure.

Example fix

// before (script) — fails when services disabled
runtimeService.setVariable(executionId, 'flag', true)

// after: enable in config
ProcessEngineConfigurationImpl cfg = ...;
cfg.setServicesEnabledInScripting(true);
// or set a variable before the script
delegateExecution.setVariable("flag", true);
Defensive patterns

Strategy: validation

Validate before calling

if (!processEngineConfiguration.isServicesEnabledInScripting()) {
    throw new IllegalStateException("script uses services but servicesEnabledInScripting is off");
}

Try / catch

try {
    return scriptingEngines.evaluate(request).getResult();
} catch (FlowableException e) {
    if (e.getMessage() != null && e.getMessage().contains("not available in the current context")) {
        throw new IllegalStateException("enable servicesEnabledInScripting or refactor script", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Executing a script that references a service bean (runtimeService.getVariable(...), etc.) when ProcessEngineConfiguration.isServicesEnabledInScripting() returns false (the default in some setups).

Common situations: Migrating scripts that relied on older Flowable/Activiti defaults where services were exposed; scripts accessing taskService or repositoryService from a gateway condition or task listener; hardened production configs disabling services for security.

Related errors


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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java:85

        this.scopeContainer = scopeContainer;
        this.inputVariableContainer = inputVariableContainer;
    }

    @Override
    public boolean containsKey(Object key) {
        return variableScopeKey.equals(key) || inputVariableContainer.hasVariable((String) key)
                || SERVICE_RESOLVERS.containsKey(key) && processEngineConfiguration.isServicesEnabledInScripting();
    }

    @Override
    public Object get(Object key) {
        if (variableScopeKey.equals(key)) {
            return scopeContainer;
        } else if (SERVICE_RESOLVERS.containsKey((String) key)) {
            if (processEngineConfiguration.isServicesEnabledInScripting()) {
                return SERVICE_RESOLVERS.get(key).apply(processEngineConfiguration);
            } else {
                throw new FlowableException("The service '" + key + "' is not available in the current context. Please enable services in scripting.");
            }
        }

        return inputVariableContainer.getVariable((String) key);
    }
}

View on GitHub (pinned to d6d39ce1c6)