[SOLVED] OH 3 Docker Image: Jython - ImportError: No module named core in <script> at line number 1

Dear community,

i’m slowly desperate with OH3 and Jython. I’ve been trying to get Jython working for days, but without success.

I ran OH3 as a Docker image, installed the Jython add-on, the current helper libraries were downloaded from ivans github-channel and copied into the container, the permissions openhab:openhab for the folder “automation” were set recursively, the karaf-console configured accordingly and i always get the following error message:

Script execution of rule with UID ‘test’ failed: ImportError: No module named core in at line number 1
(I can post the entire error message if necessary)

from core.rules import rule
from core.triggers import when

@rule("Testscript", description="This is only a test", tags=["test"])
@when("Item hue_floor_motionsensor_Bewegung changed from OFF to ON")
def TestScript(event):
    if items["dummy_switch"] != ON:
        TestScript.log.info("Turn the lights on")
        events.sendCommand("dummy_switch", "ON")

I would be really grateful if someone could help me get Jython running, as I currently have two instances running, both have been moved to OH3 and now no rule works.

Thanks in advance!

best regards
Christoph

Make sure you don’t have /var/lib/openhab/automation/automation. It looks like the helper libraries may not have been copied to the right place.

Hello @rlkoshak ,

thank you very much for your hint!

I have OpenHAB running in a Docker, unfortunately the paths are a bit different there. However, i just stumbled upon an interesting post from you - it may have something to do with it:

EXTRA_JAVA_OPTS="-Xbootclasspath/a:/openhab/conf/jython/jython.jar -Dpython.home=/openhab/conf/jython -Dpython.path=/openhab/conf/lib/python"

(JSR223 Jython with Docker openHAB)

I assume that this configuration has changed with OH3. My docker-compose configuration looks like this:

volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- openhab-addons:/openhab/addons
- openhab-conf:/openhab/conf
- openhab-userdata:/openhab/userdata
- openhab-automation:/openhab/automation

Is it possible that you can tell me the EXTRA_JAVA_OPTS configuration for OH3? That would be great because i think that’s the problem.

Thanks in advance!
Christoph

If you’ve installed the add-on, that configuration is no longer needed. Remove the extra java opts.

Okay, then unfortunately that wasn’t the problem, because i didn’t use this variable in my docker-compose file. Here are my paths with the respective content - that should actually be correct.

root@ubuntu:/openhab# ls
addons automation conf dist LICENSE.TXT runtime start_debug.sh start.sh userdata

root@ubuntu:/openhab/automation# ls
jsr223 lib

root@ubuntu:/openhab/automation/lib# ls
groovy javascript python

root@ubuntu:/openhab/automation/lib/python# ls
community configuration.py core personal

root@ubuntu:/openhab/automation/lib/python/personal# ls
__ init__.py

The automation folder needs to be under the conf folder.

/openhab/conf/automation

@rlkoshak you are the best, that was the problem - thank you very much for your help!

best regards
Christoph