Java error while loading sitemap

What’s wrong with the following sitemap code?

sitemap test label=“Test-Umgebung” {

Frame label=“Licht” {
Switch item=eg_wz_dimmer
Slider item=eg_wz_dimmer
}
}

In the Log I see the following error:

2017-07-07 21:12:55.327 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘test.sitemap’
2017-07-07 21:12:55.341 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘test.sitemap’ is either empty or cannot be parsed correctly!
2017-07-07 21:12:55.345 [ERROR] [.core.internal.folder.FolderObserver] - Error handling update of file ‘/etc/openhab2/sitemaps/test.sitemap’: null.
java.lang.NullPointerException
at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.getAllItems(PageChangeListener.java:125)[117:org.eclipse.smarthome.io.rest.sitemap:0.9.0.b5]
at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.updateItemsAndWidgets(PageChangeListener.java:75)[117:org.eclipse.smarthome.io.rest.sitemap:0.9.0.b5]
at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.sitemapContentChanged(PageChangeListener.java:217)[117:org.eclipse.smarthome.io.rest.sitemap:0.9.0.b5]
at org.eclipse.smarthome.io.rest.sitemap.SitemapSubscriptionService.modelChanged(SitemapSubscriptionService.java:277)[117:org.eclipse.smarthome.io.rest.sitemap:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:286)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:136)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:234)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:297)[122:org.eclipse.smarthome.model.core:0.9.0.b5]
at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:206)[98:org.eclipse.smarthome.core:0.9.0.b5]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-07-07 21:12:55.421 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘test.sitemap’

The item is defined as follows:

Dimmer eg_wz_dimmer “Licht Wohnzimmer [%d %%]” {mqtt=“<[mosquitto:eg/wz/dimmer:state:ON:on],<[mosquitto:eg/wz/dimmer:state:OFF:off],>[mosquitto:eg/wz/dimmer/set:command:ON:on],>[mosquitto:eg/wz/dimmer/set:command:OFF:off]”}

I don’t know if it solves the problem, but I would NEVER give the same item name to two different items, even if they are different item types.

I actually defined only one item. It’s a dimmer called “eg_wz_dimmer”. My objective is to use the switch to turn the light on or off while using the slider to fine tune the intensity of the light.

A dimmer item accepts 0-100, a switch accepts ON and OFF.
I never tried to bond an ON/OFF device to a dimmer item, but I guess that is your problem.

Long story short: remove the slider item from your sitemap and see if the error disappears…

Edit: and make your item a switch item

Well, zero should correspond to “off”, while 100 should correspond to “on”.

Okay, I don’t know your device, not of any help here, sorry

The Java error didn’t disappear :frowning:

:joy:

I can just say that there is no problem to use the same item for different elements in a sitemap, even of different kinds like in your example. Your problem is elsewhere.

1 Like

At first glance your sitemap looks ok to me. Did you check the file permissions of the test.sitemap file? Is the user running openHAB able to read the test.sitemap file?

What kind of editor are you using? Could it be that you have a problem similar to:

I am not a linux pro. How am I supposed to check it? Log in via SSH and then what?

Microsoft Visual Studio Code

Actually, the sitemap is loading as expected. I wouldn’t have expected a problem when I didn’t come along this error message in the log. So, one could argue that I shouldn’t care. But I do care :wink:

I would try to recreate the file from scratch. It’s a simple one and it shouldn’t take you too much time.
How do you copy the file over to the OH2 system? (are you using openHABian with a rPi3?)

No improvement. I completely recreated it from scratch (no copy & paste).

Yes, I’m using openHABian with an RPi3. I use the samba shares in conjunction with VS Code and Windows 10.

I also have another sitemap with some more items that produces the same error message. However, all items are properly working. It’s a bit strange…

If the sitemap loads ok, then file permissions is not the problem. However, if you’d like to double check then first check the user who is running openHAB:

Login using SSH into your openHAB server and execute the following command:

ps -ef | grep openhab

The left most column shows the username.

Example output (I cut off part of the result):

marcel@openhab:~ $ ps -ef | grep openhab
avahi      419     1  0 Jun29 ?        00:01:38 avahi-daemon: running [openhab.local]
openhab    671     1  0 Jun29 ?        00:00:00 /bin/bash /usr/share/openhab2/runtime/bin/karaf server
openhab    924   671  1 Jun29 ?        03:34:03 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 ....
marcel   25358 25039  0 22:50 pts/0    00:00:00 grep --color=auto openhab
marcel@openhab:~ $ 

So here we can see that on my system the openhab user is running openHAB.

Next check the file permissions:

marcel@openhab:~ $ ls -l /etc/openhab2/sitemaps
total 12
-rw-r--r-- 1 openhab openhab 6408 Jun  7 21:53 default.sitemap
-rw-rw-r-- 1 openhab openhab  230 May 15 20:54 readme.txt
marcel@openhab:~ $ 

The file permissions for my default.sitemap are as follows:

  • Read/Write permissions for the owner (in this case openhab)
  • Read permissions for the group (in this case the group is also called openhab. The first openhab is the user, the second openhab is the group)
  • Read permissions for other (meaning any other user).

I also see the ‘Configuration model ‘test.sitemap’ is either empty or cannot be parsed correctly!’ errors in my log file. I do not experience the nullpointer exceptions, but I think that they have the same cause.
You are editing your sitemap file from a remote computer. When saving the file, openHAB is informed by the OS of a change in the file and starts reloading the file. However, since you’re saving the file over the network on the remote node running openHAB this saving takes too long, or openHAB starts reading too quickly. So the file is simply not complete when openHAB reads it. In the end openHAB succeeds in reading the sitemap as can also be seen by the last line of your log:

2017-07-07 21:12:55.421 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.sitemap'

I wouldn’t say that this is all normal and how it should be, but it is nothing to worry about.

Reason for edit: fixed the formatting a bit

Same for me.

[23:20:21] openhabian@openHABianPi:~$ ls -l /etc/openhab2/sitemaps
total 16
-rw-rw-r-- 1 openhab openhabian 815 Jul 7 21:14 home.sitemap
-rw-rw-r-- 1 openhab openhabian 230 Jan 22 21:40 readme.txt
-rw-rw-r-- 1 openhabian openhabian 143 Jul 7 22:59 test.sitemap
drwxrwxr-x+ 4 openhab openhabian 4096 Jun 12 22:43 workspace

All right then. As I don’t experience any difficulties operating the sitemap, I forget the error messages for now :wink:

I just responded to another similar post here

I don’t think it’s the contents of the sitemap that’s causing this.

I just opened an issue for this problem.

1 Like

This looks very much like the old “file encoding” issue that I had a while back.

What are you using to edit your files? Notepad++ by any chance??? It has something to do with UTF8 encoding, choose “Encoding”, “Encode in UTF-8-BOM” from the menu’s then save. Oddly though, I get a similar “Configuration model ‘home.rules’ is either empty or cannot be parsed correctly!” error with my rules file regardless of encoding, so am having to use normal notepad.exe for editing (or I edit with notepad++ locally on Windows, upload the file, then run vi to edit on my linux appliance, then make a simple change and save the file and voila, it works)

On Windows I am using Notepad++ and Visual Studio Code (with the openHAB extension). On Mac, when I use TextWrangler the get the exception, but gedit does not.