If you installed via apt-get (otherwise the paths are different but the advice is the same):
Have a look if you have a file /var/lib/openhab2/config/org/openhab/modbus.config, see if it has incorrect contents. If it does, stop openHAB, delete the file, start openHAB. When /etc/openhab2/services/modbus.cfg is then re-read, the contents of /var/lib/openhab2/config/org/openhab/modbus.config will be re-created with matching contents.
To be sure that i config the correct file i did another test. In my /etc/openhab2/services/modbus.cfg i put another configuration called tester in. In /var/lib/openhab2/config/org/openhab/modbus.config it appears. I delete the tester in modbus.cfg and stopped openhab2.service. Then i removed the modbus.config file and restart the openhab2.service. In the “new” generated modbus.config the tester still appears.
[12:56:13] pi@openHABianPi:/etc/openhab2$ ls -al /etc/openhab2/services
drwxrwxr-x 2 openhab pi 4096 Feb 12 11:42 .
drwxrwxr-x 13 openhab pi 4096 Feb 2 16:35 ..
-rw-rw-r-- 1 openhab pi 2194 Jan 22 21:40 addons.cfg
-rw-r--r-- 1 openhab openhab 465 Jan 29 20:08 http.cfg
-rw-r--r-- 1 pi pi 2499 Feb 12 11:42 modbus.cfg
-rw-rw-r-- 1 openhab pi 328 Jan 22 21:40 readme.txt
-rw-rw-r-- 1 openhab pi 2390 Jan 22 21:40 runtime.cfg
-rw-r--r-- 1 pi pi 1714 Feb 1 19:25 tcp.cfg
-rw-r--r-- 1 pi pi 306 Dec 25 12:01 telegram.cfg
-rw-r--r-- 1 openhab openhab 236 Jan 29 22:00 voicerss.cfg
-rw-r--r-- 1 pi pi 224 Feb 11 08:57 weather.cfg
There is only one modbus.cfg. I could of course openhab freshly install, but then I still do not know what the error was.
I suggest correcting the file ownership differences you find, so all files are owned by the user under which the openHAB server is running. While these files can be read by “other,” there may be others that cannot, or cannot be written.
I use a little shell alias:
$ cat ~pi/.bash_aliases
alias oh='sudo -u openhab'
and then prefix every command I want to do as the openhab user with oh, like
oh vi /etc/openhab2/services/mqtt.cfg
As for the source of the “ghost” entries in the configuration, I have no further suggestions at the moment, but would of course love to hear what the root cause is.
In Karaf Console config:del org.openhab.modbus. Then I made a small change in the modbus.cfg so that karaf noticed that has changed a bit. Karaf “read” the file and generate a new modbus.config. And tadaaaaa … no error.