Jython startup behaviour

I have Jython rules, defined as following:



class WashingMachinePowerRule(SimpleRule):


When my Jython files are loaded when restarting openHAB I get the following error message, where line number 20 is the line with the class definition:

NameError: name 'SimpleRule' is not defined in <script> at line number 20

When a save the file again, after openHAB has been started everything works as expected.

Is there any workarround for this problem?

Thanks for your help!

This is an openHAB issue, not specific to Jython. The openHAB OSGi bundle load order seems to be incorrect at times. I haven’t had a problem with this myself, but others have reported similar issues. It might be related to the specific set of bundles you have configured for openHAB.

I don’t know of any great workarounds. Some people have put extra delays in various parts of the startup sequence, but that doesn’t seem like a very reliable solution to me.

I have noticed these problems in openHAB 1 but until now not in openHAB 2. In openHAB 1 they where always random, bit the error regarding the Jython rule is reported every time openHAB is restarted.

But thats probably one of the reasons, why JSR223 is designated as experimental…

In your environment… I’ve been running openHAB2 JSR223 Jython since before it was released and have not had the problem.

As I said before, this is not an issue specific to JSR223. That said, the JSR223 layer is using the “experimental” rules engine of openHAB2 but it’s not clear that this is directly relevant to your issue.

Here’s a similar report of bundle load order behavior thats not related to JSR223.

Thanks for pointing this out. Until now I only observed the “file not found” issue and lots of exceptions during startup, this one was new for me.