{"record":{"id":"f9e1b740474c4580","repo":"flowable/flowable-engine","slug":"the-service-key-is-not-available-in-the-curre","errorCode":null,"errorMessage":"The service '${key}' 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-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java","lineNumber":87,"sourceCode":"        }\n        this.scopeContainer = scopeContainer;\n        this.inputVariableContainer = inputVariableContainer;\n        this.engineConfiguration = engineConfiguration;\n    }\n\n    @Override\n    public boolean containsKey(Object key) {\n        return inputVariableContainer.hasVariable((String) key) || KEYS.contains(key)\n                || SERVICE_RESOLVERS.containsKey(key) && engineConfiguration.isServicesEnabledInScripting();\n    }\n\n    @Override\n    public Object get(Object key) {\n        if (SERVICE_RESOLVERS.containsKey((String) key)) {\n            if (engineConfiguration.isServicesEnabledInScripting()) {\n                return SERVICE_RESOLVERS.get(key).apply(engineConfiguration);\n            } else {\n                throw new FlowableException(\"The service '\" + key + \"' is not available in the current context. Please enable services in scripting.\");\n            }\n        } else if (CASE_INSTANCE_KEY.equals(key)) {\n            if (scopeContainer instanceof CaseInstance) {\n                return scopeContainer;\n\n            } else if (scopeContainer instanceof PlanItemInstance planItemInstance) {\n                if (StringUtils.isNotEmpty(planItemInstance.getCaseInstanceId())) {\n                    return CommandContextUtil.getCaseInstanceEntityManager().findById(planItemInstance.getCaseInstanceId());\n                }\n\n            } else if (scopeContainer instanceof Task task) {\n                if (StringUtils.isNotEmpty(task.getScopeId()) && ScopeTypes.CMMN.equals(task.getScopeType())) {\n                    return CommandContextUtil.getCaseInstanceEntityManager().findById(task.getScopeId());\n                }\n\n            }\n\n            throw new FlowableException(\"Unsupported variableContainer for key '\" + CASE_INSTANCE_KEY + \"': \" + scopeContainer.getClass().getName());","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/scripting/CmmnVariableScopeResolver.java#L69-L105","documentation":"CmmnVariableScopeResolver.get(Object key) throws FlowableException when a script/expression references a Flowable service (e.g. cmmnEngineConfiguration service names) while isServicesEnabledInScripting() is false. This is a deliberate guard: service access from scripts is opt-in for security reasons.","triggerScenarios":"A script (Groovy/JS) in a CMMN case references a service resolver key (e.g. 'cmmnRuntimeService' style lookups on the resolver) while cmmnEngineConfiguration.setServicesEnabledInScripting(false) (the default).","commonSituations":"Migrating scripts from older Flowable versions where services were enabled by default; deploying a case with scripts that use service beans into an environment hardened with services disabled.","solutions":["Enable services in scripting: cmmnEngineConfiguration.setServicesEnabledInScripting(true).","Rewrite the script to not use engine services — obtain needed data as variables before the script runs.","Expose only required values via delegate expression fields or script bindings instead of service lookups (recommended for security)."],"exampleFix":"// before (config)\n// services disabled by default; script uses cmmnRuntimeService\n// after\ncmmnEngineConfiguration.setServicesEnabledInScripting(true);","handlingStrategy":"fallback","validationCode":"// before running scripts, check:\nif (!engineConfig.isServicesEnabledInScripting()) { sanitizeScriptsToAvoidServiceLookups(); }","typeGuard":null,"tryCatchPattern":"try { return resolver.get(key); } catch (FlowableException e) { log.warn(\"Service '{}' unavailable in scripting; returning null binding\", key); return null; }","preventionTips":["Enable setServicesEnabledInScripting(true) only if scripts legitimately need engine services.","Prefer passing required data as variables/bindings instead of service access from scripts.","Audit deployed case scripts for service references when hardening environments."],"tags":["flowable","cmmn","scripting","feature-not-enabled"],"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-14T05:17:10.506Z"}