Rule engine intermitent null exception after restart

I’ve read a number of threads and bug reports on this problem. I had this issue with 1.7.x and now on 1.8 snapshots. It is intermittent in that it only occurs after a restart and can only be resolved by another restart. There is no determinable patter to when it happens. I did some logging many months back and was under the impression it was related to the order in which items and rules were loaded.

Error during the execution of rule Midnight Off java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,org.openhab.core.types.Command) on instance: null

Updating the timestamp or editing the rules file has no positive effect. Here is a rule that causes the failure…

rule "Midnight Off"
    Time is midnight
    logInfo("Midnight","Turning off group gMidnightOff")
      sendCommand(Switch, "OFF")

I have since changed the sendCommand to…


This appears to have resolved the issue, any thoughts as to what is going on here and if its related to 2646, 2692, and 3166.

1 Like

If the problem is indeed because of the order of your files loading, you can control the order by setting the polling periods in your openhab.cfg so the rules do not start loading until after your Items and Persistence have finished loading. This is primarily a problem for those with more than one Items and Rules files.