Upgrade to 2.5.5 and having issues with JSR223

You can ignore these errors. Are your rules working? Are you using the beta Jython add-on? If not, how recent are the helper libraries?

Welcome to the forum!

Thanks for the help.
I put the new helper libraries in because of all the errors after upgrading. Some rules are working and some seem to not be. Since the error doesn’t matter I’ll look into it some more and let you know.
Thanks again

I’m getting the same error on the triggers
Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/testswitch.py’: ImportError: cannot import name bundle_context in at line number 4

from org.slf4j import LoggerFactory
from core.triggers import ItemCommandTrigger, ItemStateChangeTrigger, ItemStateUpdateTrigger, CronTrigger
from core.jsr223.scope import events, itemRegistry

and none of the triggers are firing. This is from a simple test script to check things etc.
All the files under automation were updated from openhab on github yesterday.
Rules not using triggers on updating are running ok.


If this is a script, then don’t do this. events and itemRegistry are included in the default script scope. Modules are the only place you would need core.jsr223.scope.

I have not used extensions for a while. Why not use the when decorator? I merged some changes a few days ago, but I am not seeing this error. I have some more to merge though. I’ll do some more tests though…

even with a decorator I’d still need the imports correct. I did remove the trigger and the trigger is now firing.
I changed the import for audio from
from openhab.actions import Audio
from core.actions import Audio
It fails when going to play a sound.
I don’t want to waste your time is there documentation I missed on what the calls(Imports) where and are now.
Thanks again

I setup a new test environment and can reproduce this. It must be a bug that I recently introduced. Give me a few minutes and I’ll track it down…

You wouldn’t have this problem with the beta Jython addon :wink:

On line 29 of core.osgi.events, replace…

from core.osgi import bundle_context

… with…

from core.osgi import BUNDLE_CONTEXT

… then restart OH. I’ll merge a PR tonight with a real fix, but this should get you going again.

Thanks a lot. I downloaded your addon earlier and am installing it now.
It’ll be a lot easier for most to get up and running with it.

1 Like

I installed the jar in the addons and didn’t see anything in the logs. I do have other things installed thru the addons that are working.
Is there anything you’d like me to try?

Where is the core.osgi.events file located?

When I changed the file name to end in .org the jython addon now is working, but I’m still getting the same error as before with bundle_context.
So I can fix it if you tell where core.osgi.events is located.

Thanks again…Greg

In the core libraries… $OPENHAB_CONF/automation/lib/python/core/osgi/events.py


If you use the addon, remember to remove the Jython entries from your EXTRA_JAVA_OPTS.

Which file and why did you rename it?

Thanks I was way overthinking it. I was looking for a file called core.osgi.events.

I did remove it from the extra_java_opts yesterday and renamed the jython-standalone-2.7.0.jar and rebooted. No scripts ran.
I saw someone renamed org.openhab.core.automation.module.script.scriptenginefactory.jython-2.5.0-SNAPSHOT.jar.org by adding .org at the end.
When I did that after rebooting my scripts started running again

Where did you find that? Renaming the file will not change anything and could mess some things up.

Glad you got it all working!

I think you need to change
line 10 from core.osgi.events import OsgiEventAdmin, event_dict, osgi_triggers #OSGI_TRIGGERS

I’m looking into why audio isn’t playing and will let you know what I find.

Thanks again for the help…Greg

Yes, but that wouldn’t prevent the loading of rules. I’m about the push the fix but it lured me into troubleshooting why the OsgiEventTrigger is not working!

OK… pushed!

Was this for the helper libraries?


FYI it was
org.openhab.core.library.types that was causing Audio.playSound to error

From something in the helper libraries or something of yours?