[ERROR] Cannot retrieve item for widget ...sitemap.Switch

I have been working with OH2 since a few months now with the following platform

  • Openhab 2.5.2 (just upgraded openhabian system image 2.4)
  • raspberry Pi 3 Model B Plus Rev 1.3. (+Hifi Berry AM2).

Since some time (I think after last upgrade?) I have the following error while restarting openhab2:

2020-03-13 08:45:24.709 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch

2020-03-13 08:45:28.678 [WARN ] [basic.internal.render.SwitchRenderer] - Cannot determine item type of 'ST_Brink_Level'
org.eclipse.smarthome.core.items.ItemNotFoundException: Item 'ST_Brink_Level' could not be found in the item registry

I have a proxy item ST_Brink_Level as a String Item (previously as a Number but also error reported) and as a Switch in sitemap.
After restarting OH 2 it stops on this error repeating it. So I change the item type from String to Switch in .item file for a while. When OH2 is running again after restart I change the Switch to String again to have a requested functionality. And it works, no new errror reported (!)

.items

String    ST_Brink_Level                   "Rekuperacja"             <fan>             (Home, ST)                           ["Fan"]

.sitemap

Switch item=ST_Brink_Level mappings=[1="Low", 2="Mid", 3="High"]

.rules

rule "Brink2_ON"
when
    Item GF_Toilet_Light changed from OFF to ON or Item FF_Bathroom_Light changed from OFF to ON
then
    ST_Brink_Level.postUpdate(2)
end

rule "Brink2_OFF"
when
    Item GF_Toilet_Light changed from ON to OFF or Item FF_Bathroom_Light changed from ON to OFF
then
    if (FF_Bathroom_Light.state == ON || GF_Toilet_Light == ON) {
        return;
   }
   else
    ST_Brink_Level.postUpdate(1) 
    ST_Brink_2.sendCommand(OFF)
end

So why I am asking for help? Because after ~ 1 day OH2 slows down/stops with another error: " Dispatching event to subscriber ‘…’ takes more than 5000ms" (memory leak?). And I think it might relate to the previous error?
Is there anything wrong in my item and sitemap definition?

I don’t know what you’re doing, I don’t suppose openHAB does either.

Stop openHAB
Edit your xx.items file to be a Number Item, as you want.
Do the cache-clean thing

I doubt that’s related to your slow down, but one step at a time.

I am really surprise with such a quick response on my post - thank you!

I have done already stop/clear cache/start OH2 based on the info I have found in this community.

I have just repeated it again (and before it I changed ST_Brink_level from String to Number in .items file).
But the error is the same (error message and warning with number of java related messages - I only put first lines below):

2020-03-13 22:21:20.757 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-13 22:21:20.764 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-13 22:21:20.768 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-13 22:21:51.735 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-13 22:21:51.738 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-13 22:21:51.741 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch

020-03-13 22:22:20.604 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /rest/sitemaps/Doskonaly/Doskonaly
javax.servlet.ServletException: javax.servlet.ServletException: A MultiException has 1 exceptions.  They are:
1. java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_1,2,14803227) has been shut down
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:88) ~[bundleFile:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
//---> few screens of lines follows

I was waiting ~ 20 minutes but not all frames and names of items on the sitemap are avaiable.

So I have edited .items file and changed Number type of ST_Brink_Level item to Switch, saved the file and looked at logs. I can see OH2 initialized all remining values and all items and frames are available now.
But I cannot control ST_Brink_Level as 3 position switch. So I edited .items file again and change from Switch to Number of the ST_Brink_Level item.
Everything works correctly, no errors in log.

I am puting my rules again since I have omited few related to ST_Brink_Level

rule "Brink2_ON"
when
    Item GF_Toilet_Light changed from OFF to ON or Item FF_Bathroom_Light changed from OFF to ON
then
    ST_Brink_Level.postUpdate(2)
end

rule "Brink2_OFF"
when
    Item GF_Toilet_Light changed from ON to OFF or Item FF_Bathroom_Light changed from ON to OFF
then
    if (FF_Bathroom_Light.state == ON || GF_Toilet_Light == ON) {
        return;
   }
   else
    ST_Brink_Level.postUpdate(1) 
    ST_Brink_2.sendCommand(OFF)
end


rule "Brink_level_1"
when
    Item ST_Brink_Level changed to 1
then
    ST_Brink_1.sendCommand(ON)
    ST_Brink_2.sendCommand(OFF)
    ST_Brink_3.sendCommand(OFF)
end

rule "Brink_level_2" 
when
    Item ST_Brink_Level changed to 2
then
    ST_Brink_1.sendCommand(OFF)
    ST_Brink_2.sendCommand(ON)
    ST_Brink_3.sendCommand(OFF)
end

rule "Brink_level_3"
when
    Item ST_Brink_Level changed to 3
then 

    ST_Brink_3.sendCommand(ON)
end

Also in Visual Studio Code, while editing the rule I had the error “The method or field ST_Brink_level is undefiend” May be the proxy item ST_Brink_Level shall have an assigned/initialized value at the OH restart/load?

aargh, stop it. Set the Item to what you want, a Number type. Keep changing to something else isn’t helping, just adding chaos.
Then do the clear cache thing again.

This is straightforward and means what it says.
It cannot find any Item by that name.
The type is completely irrelevant here.
The “Switch” it is talking about is the sitemap widget that calls for the Item by name. Not the type.

So, why can’t it find that Item?

a) there is perhaps something wrong with your xxx.items file.
Look in your openhab.log for load messages about that file.

b) After an upgrade or after a clean cache, people do report that it can two or three reboots to get all Items correctly created. Rebuilding the cache, I suppose.

I have performed several stop/clean-cache/restart but the problem persists and I have the following findings:

  • any time I restart with clean-cache first it does NOT work: the same warning and errors appear and not all frames and names are available.
  • but when I restart again without clean-cache first, no errors appears in the log and sitemap works correctly.

My conclusion:
Seems that OH2 has a problem to load first time items which: (i) do not have channels assigned and (ii) are specified as different types in both .items and .sitemaps . After second restart (without clean-cache) OH2 knows already the type of such an item and error does not appear.

In my x.items file there are only 2 items without channels assigned which are: ST_Brink_Level and ST_Brink_1

In Visual Studio Code in .rules file (but not in .items nor .sitemap file) I can see the following problems

“The method or field ST_Brink_level is undefined”
“The method or field ST_Brink_1 is undefined”
Both might not be registered while loading but the issue is with the one visible on the sitemap.

After stopping OH2, cleaning-cache and restarting I have the fallowng warning and errors:

2020-03-14 11:42:59.242 [WARN ] [basic.internal.render.SwitchRenderer] - Cannot determine item type of 'ST_Brink_Level'
org.eclipse.smarthome.core.items.ItemNotFoundException: Item 'ST_Brink_Level' could not be found in the item registry
	at org.eclipse.smarthome.core.internal.items.ItemRegistryImpl.getItem(ItemRegistryImpl.java:85) ~[?:?]
	at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.getItem(ItemUIRegistryImpl.java:837) ~[?:?]
// number of lines ->
//then 
2020-03-14 11:42:59.282 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ST_Brink_Level' for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch
2020-03-14 11:42:59.284 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Switch

Then I stop OH2, then restart (without clean-cache) and no warning/error reported in logs :slight_smile:

So, what is the state of play now? Cannot tell from that.

OH2 is working! But if I need to make an OH2 restart with clean-cache for any reason, I need to do it twice:
First time with clean-cache => I can not use OH2 fully (error and not all frames available)
Then the second stop/start (without clean-cache) => no errors in log and OH2 works

Also, yesterday I turned off the power supply to my PI3, then I turned the power supply on and performed again all ugpardes/updated available using sudo openhabian-config. Just after that the first OH start was without errros (but I don`t remeber if I cleaned cache :confused: .) After some time I needed to restart OH2 (added new functionality to OH2 - RFXcom binding) and the behaviour of the OH2 was as described above (restart with clean-cache, then restart without clean cache)

Yes, this is well known in this forum.

Hi -

just realised that I have the exact same issue … need to do multiple stop - clean-cache - start before my virtual items or the iOS app are working properly.

Never had this issue until recently.

Did anyone ever figure out what the reason for this is or is there a better work around?

Running OH2 2.5.9 - really thought there is a fix considering “well known” :slight_smile:

Well, the fix is not to clear your cache unnecessarily. It’s not supposed to be a routine action. You are forced into that by upgrades, though.
Why it takes two attempts to re-populate it, I don’t know.