Jython in Docker

Openhab Version: 2.5.2

I am trying to get Jython scripting to work inside a docker install of Openhab.
Until now I installed the experimental rule engine and Jython as well as the openhab-helper-libraries following this Docker Guide combined with this general Guide since the general one seems to be a bit out of date.
The following java options get passed to the Openhab docker container EXTRA_JAVA_OPTS=-Xbootclasspath/a:/openhab/conf/automation/jython/jython-standalone-2.7.0.jar -Dpython.home=/openhab/conf/automation/jython -Dpython.path=/openhab/conf/automation/lib/python.

My problem now is that I can see in the logs that the JS script engine gets loaded, but the Python one does not get activated.
Can someone point out to me what I am missing?

Log Excerpts
16:36:06.895 [DEBUG] [r.AutomationResourceBundlesEventQueue] - Process bundle event 2, for automation bundle 'org.openhab.core.automation' 
16:36:06.898 [DEBUG] [r.AutomationResourceBundlesEventQueue] - Process bundle event 32, for automation bundle 'org.openhab.core.automation.module.script.rulesupport' 
16:36:06.900 [DEBUG] [ovider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation' 
16:36:06.901 [DEBUG] [ovider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation.module.script.rulesupport' 
16:36:06.953 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added CoreModuleHandlerFactory
16:36:06.954 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added EphemerisModuleHandlerFactory
16:36:06.955 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added TimerModuleHandlerFactory
16:36:06.955 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedActionModuleTypeProvider
16:36:06.969 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedThingActionModuleTypeProvider
16:36:06.987 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added MediaModuleHandlerFactory
16:36:07.351 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
16:36:07.362 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
16:36:07.364 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Removed GenericScriptEngineFactory
16:36:07.364 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Removed NashornScriptEngineFactory
16:36:07.385 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
16:36:07.392 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
16:36:07.394 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptModuleHandlerFactory
16:36:07.432 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedCustomModuleHandlerFactory
16:36:07.435 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedPrivateModuleHandlerFactory

16:36:32.452 [INFO ] [ome.core.service.AbstractWatchService] - Loading script 'javascript/core/000_startup_delay.js'
16:36:32.701 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'js' with identifier: file:/openhab/conf/automation/jsr223/javascript/core/000_startup_delay.js
16:36:32.754 [INFO ] [jsr223.javascript.core.startup_delay ] - Checking for initialized context
16:36:32.774 [INFO ] [jsr223.javascript.core.startup_delay ] - Context initialized... waiting 30s before allowing scripts to load
16:37:02.788 [INFO ] [jsr223.javascript.core.startup_delay ] - Complete

Hi @BifbofII, welcome to the forum!
I recommend you to use the Jython addon which has almost everything integrated.

1 Like

Thank you, I got it working now with the addon.
Is there a plan for merging this addon into the next release?

Welcome to the community and scripted automation!

I hope to get this added as an addon into 2.5.x. Hopefully, this will be ready by the next release. You’d then be able to install it through Paper UI. For OH 3.0, things are still being worked out as to where automation, scripted automation, ScriptEngineFactories, ModuleTypes, rule templates, automation bundles, etc. will reside.

Could you please elaborate on what you mean by the general one being out of date? I would expect that if anything is out of date, it would be the docker docs. If something is out of date, I will get it sorted… or you could submit a PR to get it cleaned up.

Thank you for your answer, I’m looking forward to seeing this getting integrated into one of the next releases.

Sorry, I was getting confused when writing this. I did indeed intend to say that the docker guide seems to be a bit out of date.
What I noticed was that the instructions here are referencing the old repository and the mv command fails. The wget seems to be forwarded to the new repository.

I created a PR with the changes that I suggest, however I did not validate that the instructions do work now (since I got my install working with the addon). I think they should be pretty safe changes though.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.