{"record":{"id":"d123892b00dc12c4","repo":"flowable/flowable-engine","slug":"the-service-is-not-available-in-the-current-con","errorCode":null,"errorMessage":"The service '' is not available in the current context. Please enable services in scripting.","messagePattern":"The service '' is not available in the current context\\. Please enable services in scripting\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java","lineNumber":85,"sourceCode":"        this.scopeContainer = scopeContainer;\n        this.inputVariableContainer = inputVariableContainer;\n    }\n\n    @Override\n    public boolean containsKey(Object key) {\n        return variableScopeKey.equals(key) || inputVariableContainer.hasVariable((String) key)\n                || SERVICE_RESOLVERS.containsKey(key) && processEngineConfiguration.isServicesEnabledInScripting();\n    }\n\n    @Override\n    public Object get(Object key) {\n        if (variableScopeKey.equals(key)) {\n            return scopeContainer;\n        } else if (SERVICE_RESOLVERS.containsKey((String) key)) {\n            if (processEngineConfiguration.isServicesEnabledInScripting()) {\n                return SERVICE_RESOLVERS.get(key).apply(processEngineConfiguration);\n            } else {\n                throw new FlowableException(\"The service '\" + key + \"' is not available in the current context. Please enable services in scripting.\");\n            }\n        }\n\n        return inputVariableContainer.getVariable((String) key);\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":92,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java#L67-L92","documentation":"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.","triggerScenarios":"Executing a script that references a service bean (runtimeService.getVariable(...), etc.) when ProcessEngineConfiguration.isServicesEnabledInScripting() returns false (the default in some setups).","commonSituations":"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.","solutions":["Set processEngineConfiguration.setServicesEnabledInScripting(true) if service access from scripts is intended.","Prefer passing required data as process variables before script execution instead of calling services from scripts.","Move service calls into a JavaDelegate or task listener (Java code), keeping the script pure."],"exampleFix":"// before (script) — fails when services disabled\nruntimeService.setVariable(executionId, 'flag', true)\n\n// after: enable in config\nProcessEngineConfigurationImpl cfg = ...;\ncfg.setServicesEnabledInScripting(true);\n// or set a variable before the script\ndelegateExecution.setVariable(\"flag\", true);","handlingStrategy":"validation","validationCode":"if (!processEngineConfiguration.isServicesEnabledInScripting()) {\n    throw new IllegalStateException(\"script uses services but servicesEnabledInScripting is off\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return scriptingEngines.evaluate(request).getResult();\n} catch (FlowableException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not available in the current context\")) {\n        throw new IllegalStateException(\"enable servicesEnabledInScripting or refactor script\", e);\n    }\n    throw e;\n}","preventionTips":["Keep scripts free of engine service calls; pass data as variables instead","If services are required, set setServicesEnabledInScripting(true) explicitly at config time","Audit existing scripts after upgrading — service exposure defaults may differ","Move service interactions into JavaDelegates or listeners"],"tags":["flowable","scripting","security","configuration"],"backgroundTag":"feature-not-enabled","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}