diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java index 6a695d6e7ba..49e3b3a9f7a 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/AbstractScriptModuleHandler.java @@ -105,6 +105,7 @@ protected void compileScript() throws ScriptException { ScriptEngine scriptEngine = engine.get(); if (scriptEngine instanceof Compilable) { logger.debug("Pre-compiling script of rule with UID '{}'", ruleUID); + setExecutionContext(scriptEngine, Map.of()); // JRuby script engine needs this before compiling compiledScript = Optional.ofNullable(((Compilable) scriptEngine).compile(script)); } } @@ -211,7 +212,7 @@ protected void resetExecutionContext(ScriptEngine engine, Map context try { if (compiledScript.isPresent()) { logger.debug("Executing pre-compiled script of rule with UID '{}'", ruleUID); - return compiledScript.get().eval(engine.getContext()); + return compiledScript.get().eval(); } logger.debug("Executing script of rule with UID '{}'", ruleUID); return engine.eval(script);