Problems after install of JSR223 scripts

Hi,

I’m running openhab in an ARM_ODROID_XU/2Gb/512GB using OS Ubuntu 18.04.3 LTS. The JVM is 1.8.0_181-b13. On the top, I have an openHAB version 2.4 running.

My problem:

After following the very detailed instructions (thanks for this work guys) available at https://openhab-scripters.github.io taking care of not missing any of the items.

I managed to install both the New generation rule engine and all the community scripts in both jsr223 and lib folder. I tried both the files contained in the file master.zip, that can be downloaded from the website, and also I tried with the master branch fetched with git.

As suggested in the instructions, I test it using the hello_world.py but it fails, showing:

2019-09-15 15:47:09.286 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/personal/hello_world.py'
2019-09-15 15:47:09.724 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py': TypeError: Error when calling the metaclass bases

Actually, the line producing the error is the second one of the import section:

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

IMHO, the problem affecting hello_world.py comes first during the initialisation of the scripts. It waits for the context to be ready up to 30 seconds, but one of the scripts (100_OsgiEventTrigger.py) fails (the rest are fine):

2019-09-15 16:00:43.572 [INFO ] [jsr223.jython.core.startup_delay    ] - Complete
2019-09-15 16:00:43.575 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/core/000_startup_delay.py
2019-09-15 16:00:43.576 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/100_DirectoryTrigger.py'
2019-09-15 16:00:46.130 [INFO ] [23.jython.core.DirectoryEventTrigger] - TriggerHandler added [jsr223.DirectoryTrigger]
2019-09-15 16:00:46.139 [INFO ] [23.jython.core.DirectoryEventTrigger] - TriggerType added [jsr223.DirectoryTrigger]
2019-09-15 16:00:46.140 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/core/components/100_DirectoryTrigger.py
2019-09-15 16:00:46.142 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/100_OsgiEventTrigger.py'
2019-09-15 16:00:47.232 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': TypeError: Error when calling the metaclass bases
    cannot create 'NoneType' instances in <script> at line number 17
2019-09-15 16:00:47.233 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/core/components/100_OsgiEventTrigger.py

The line (16) producing the error is the following:

16:  import core
17:  from core.osgi.events import OsgiEventAdmin, event_dict, osgi_triggers
18:  from core.log import logging, LOG_PREFIX
  • Please post configurations (if applicable):
    There are two python versions 2.7 and 3 running in the machine, but i’m sure it is taking 2.7. The jython bundle is 2.7.0, but also tried with 2.7.1

    • Items configuration related to the issue
      I think it does not apply but, openhab manages a KNX system and several other MQTT DIY electronics and some zigbee components visible to the system by means of MQTT (instead of using the zigbee binding)

    • Sitemap configuration related to the issue
      No sitemap related to the tipic

    • Rules code related to the issue
      Just the helloworld provided as a Script Example

Thanks in advance

Dani

I suggest removing all of the community scripts and packages until your hello_world.py is running properly, and then only add the ones you are going to use.

Are you using a full install of Jython or the standalone? I’ve only seen that error when using a CPython module, like requests. I’ll spin up my 2.4 test environment and see if something may have broken in the helper libraries, but this sounds like a configuration issue. Please post your EXTRA_JAVA_OPTS.

The load order of scripts was an issue until this PR. You would need at least 2.5M2 to get this. Before this PR, the script load order was causing some problems and the community scripts would load before the core scripts. If you want to keep using 2.4 (I suggest upgrading) with community scripts, rename /automation/jsr223/python/core/ to /automation/jsr223/python/000_core/ and restart OH.

Jython does not use Python.

@5iver I just updated my production copy of OH and got the same errors on S1645 and Jython 2.7.0 JAR.

The rest of the core scripts load fine, but then any attempts to import from core.triggers results in the same error because it is trying to import core.osgi.events.OsgiEventTrigger

I will update my test container to the latest snapshot and update this post.
Updated to S1689 and same problem. Groovy and JS are fine though.
I’m going commit by commit to find what changed.

Don’t bother… I found the problem and then promptly took a nap :roll_eyes:. I accidentally included a change that was not ready to go out yet.

-_- I just found the commit lol

Do tell, or push an update

Thanks for the hint. I did not want to upgrade to 2.5M2 as 2.40 is quite reliable for my KNX automation but I really need the the new rules (my DSL rules are becoming hard to manage.

I will upgrade and came back to let you know in one or two days

Thanks

I have fixed the imports that I’d messed up (sorry and thank you for reporting!)… try the lastest version of the helper libraries, or just update core.osgi.events (the only file needing a change).

Hi there,

After upgrading to Openhab 2.5M3 everything working fine (KNX, MQTT…) and scritps loading perfectly!
No error during community scripts loading and hello_world working fine.

Congratulations for this very good job!

Thanks for you help

1 Like

Running OH 2.5.0 release with the beta package for the Jython addon, I noticed an error in the log:

[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: cannot import name osgi_triggers in <script> at line number 17

The other scripts in that directory seem to evaluate just fine and my first handful of Python rules are running just fine.

Before I dive deeper into this: is this a known issue or should I dive deeper into it?