No reloading of changed rules files after migartion from OH 3.4 to OH4.1

Hi all,
I need your help: I just migrated from 3.4 to 4.1 and basically everything works, except for rules aren’t reloaded after I change them. Any hints? Thanks!

Hardware: AMD64
OS: debian bookworm (12)
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb12u1)
openHAB version: 4.1

Some odd log in the console log, but not sure if it is related:

10:55:08.852 [WARN ] [f.transport.servlet.ServletController] - Can't find the request for http://namibia:8080/rest/events/states's Observer 
10:55:10.072 [INFO ] [.community.CommunityKarafAddonHandler] - Reinstalling missing marketplace KAR: marketplace:138795

And what I did so far:

  • deleted cache
  • checked path of /etc/openhab - which is correct
  • searched this forum but couldn’t find anything matching

Please check in the Addxon Store if the add-on for your script language is installed.
Could you be more precise what you mean with „reloaded“? Be aware that a script takes about 20 seconds for the FIRST ru after the rule has been changed…

The first error message is nothing to worry about. This happens during restarting openhab when a client is currently active.
For the second error message try to reinstall the marketplace add-on again.

Also check your file / directory permissions

Thanks for your answer and sorry for not being clear enough about “reloaded”. In OH3 when ever I edited a rule file and saved it, it was reloaded by openhab within seconds and a message about this was printed in the log console.

Now the rules are loaded at start of OH4 and executed - therefor I don’t think there are script addons missing. But this described reload is missing. If I edit a rule, I have to restart the openhab service to test my edition.

Concerning the marketplace add-on error: I can’t find any marketplace add-on. Is this something specific?

all on openhab and changed date can be seen in test.rules

/etc/openhab/rules $ ls -la
insgesamt 72
drwxrwsrwx+  2 openhab openhab 4096 29. Dez 18:38 .
drwxrwsrwx+ 16 openhab openhab 4096 29. Dez 15:30 ..
-rwxrwxrwx+  1 openhab openhab 2645 25. Mär 2023  daytime.rules
-rwxrwxrwx+  1 openhab openhab 1167  3. Mai 2020  default.rules
-rwxrwxrwx+  1 openhab openhab  428 16. Mär 2020  garage.rules
-rwxrwxrwx+  1 openhab openhab  223 26. Jan 2020  readme.txt
-rwxrwxrw-+  1 openhab openhab 4276  6. Nov 2022  rhasspy.rules
-rwxrwxrwx+  1 openhab openhab 2568  8. Mär 2020  sensor.rules
-rwxrwxrwx+  1 openhab openhab 4028  3. Jan 10:58 solar.rules
-rwxrwxrwx+  1 openhab openhab 5099 23. Feb 2023  sonoff.rules
-rwxrwxrw-+  1 openhab openhab  949  3. Jan 12:09 test.rules
-rwxrwxrw-+  1 openhab openhab  861 28. Mär 2023  timer.rules
-rwxrwxrwx+  1 openhab openhab 2324 29. Dez 16:29 wallmote.rules
-rwxrwxrw-+  1 openhab openhab 1810  6. Nov 2022  Waschmachine.rules

What’s your way of editing a rule file ?

PS: I will try again myself by using vi on my RPI but I am already sure that it works.

I use Visual Studio Code, but using nano via SSH didn’t work either

BTW: to edit files on this headless server with openhab, I use a link in /etc/openhab to a shared folder. Not sure this is connected - it has been working since OH1 this way.

lrwxrwxrwx   1 openhab openhab    30 26. Jan 2020  openhab -> /sharedfolders/openhab/config/

Please test the following:
create a rule which just adds a message to the log file, run that rule and wait 20 seconds. Does that message appear in your logs?

Ok, this is the test rule created in a new file. Nothing happend even after 5 minutes

rule "Log every 2 Minutes"
    // Triggere die Regel alle 2 Minuten
    Time cron "0 0/2 * 1/1 * ? *"
    logInfo("Rule test", "Run the Rule " )

In OH4.0, the code in OH that monitored the changes of files was replaced to use the following library:

@J-N-K could probably explain better than me why this change was done but I believe it was for simplification and to solve existing issues.
Unfortunately, the new library also has issues, apparently not the same. As the consequence (my opinion), this change is not a full success.
One issue for this library in GitHub (about symbolic links) could match your case : Add an option to follow symlinks · Issue #30 · gmethvin/directory-watcher · GitHub
So please try without a symlink to confirm that this is the root cause.
This other issue could be also annoying : Does it work with mounted volumes with Docker? · Issue #86 · gmethvin/directory-watcher · GitHub

Thanks, @Lolodomo - this was the reason why it didn’t work any longer. I changed my setup now w/o a link and it works again.

@J-N-K @wborn : a bug to keep in mind and maybe even to trace as issue in GitHub even if the bug is in the library we relies on.

There were similar feedbacks when 4.0 was released, maybe it was due to usage of symlinks by these users.

1 Like

I have the same problem since migration to OH 4.1 But sorry, I cannot follow the described way to solve the problem. Could anybody explain the solution in a more detailed kind? Thank you in

Looks similar to: