Common Rules errors and their solutions

I was waiting until I had a really good list of things to post but decided this would be better done as a collaborative effort.

So everyone post some Rules errors you have encountered, what they mean, and how you solved them.

I’ll start with a couple.

Rule Errors and their actual Meaning

  • IllegalStateException: this occurs when you have two copies of a Rule running at the same time trying to access the same data, in particular a container like a HashMap or List. Put a ReentrantLock around the access or the entire rule so only one instance can access the data at a time.

  • NullPointerException: this is a catchall exception which usually means:

    • you are referencing an Item that doesn’t exist
    • you are trying to cast the state of an Item that is NULL/Undefined to a type (e.g. DecimalType)
    • you are trying to parse a String into a Number and the String is of an invalid format
  • Ambiguous method call: this usually occurs when you try to call the postUpdate or sendCommand using a DecimalType. The problem is a DecimalType is also a Number and there are two different methods, one that takes a DecimalType and one that takes a Number and the interpreter doesn’t know which one you meant. Cast the DecimalType to Number.

More to follow. Please share your own!

4 Likes
 Great topic, Rich, Here's more cryptic error messages...

An error occured during the script execution: index=1, size=1
Seems to indicate that something OpenHAB expects was omitted:
like a matching bracket, a keyword, or a leading zero (like .05 instead of 0.05)

Maybe the above narrows what one is searching for to correct the error.

To help find missing brackets, paste offending rules into an editor such as Notepad++. When the cursor is near one bracket, such editors highlight what it sees as the matching bracket.


“cannot be resolved to an item or type” somehow violates using items or types
If we try to relate two things, they must match in type. The error can result when …
We omit the tag .state after an item name.
We use a string type where a number type is expected or vice versa.
We try to compare two things without making sure their types (String, Decimal, etc) match

Rich, your post here gives a useful tutorial on types.

1 Like

"Cannot retrieve item"
In my case it indicated that in my sitemap I used a wrong item-name.
Can be caused by a upper/lower case issue: Sonos01_StandAlone and Sonos01_Standalone

Error in openhab.log:

2017-03-12 07:12:34.281 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Sonos01_Standalone' for widget org.eclipse.smarthome.model.sitemap.Switch

In my item-file I had:

Switch Sonos01_StandAlone "MySwitch [%s]" channel="sonos:PLAY1:RINCON_xxxxxxxxxxxxxxxxx:standalone"}

In my sitemap-file I had:

Switch item=Sonos01_Standalone
1 Like