JRule - openHAB Rules using Java

Here you can find the console output when I installed JRule from the marketplace. No errors.

I can try to reproduce this on my openHAB instance earliest around the 20th.

I appreciate it!

After reverting to OH 4.1.3, I discovered that the console output after installing JRule on OH 4.2.0 is missing the following lines:

21:49:04.755 [INFO ] [n.jrule.internal.handler.JRuleHandler] - Instantiated JRuleActions class
21:49:04.761 [INFO ] [jrule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Found no classes to load into memory in folder: /etc/openhab/automation/jrule/rules
21:49:04.765 [INFO ] [jrule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Found no user defined java rules to load into memory in folder: /etc/openhab/automation/jrule/rules-jar
21:49:04.773 [INFO ] [n.jrule.internal.handler.JRuleHandler] - [JRuleHandler] JRule Engine Initializing done! 
********   Loaded 0 rule classes, change 0
********   Loaded 0 rule methods, change 0
********   Loaded 0 item state triggers, change 0
********   Loaded 0 channel triggers, change 0
********   Loaded 0 timed triggers, change 0
********   Loaded 0 thing triggers, change 0

Uploading the pre-compiled JAR to the right folder on OH 4.1.3 triggers JRule to load it immediately.

Are your rule classes in the correct package? Ran into a similar issue where rules would not get loaded because I put them in my own package. You need to put them into org.openhab.automation.jrule.rules.user or add org.openhab.automation.jrule.package=your.package into jrule.conf

Yes, the rules are under

org.openhab.automation.jrule.rules.user

They are the same rules I was running with OH 4.1.3, just they didnā€™t work right after I upgraded to 4.2.0.

What I think the issue is (check my previous comment), is that JRule is not fully loaded. Iā€™ve no idea what is blocking it. I donā€™t know what log would report the issue, as I donā€™t see anything in the standard ones.

Good lead is that
Instantiated JRuleActions class
Is missing in 4.2.1. I did not check the source code, but before this and after
Instantiated JRuleThings class I expect something to be loaded (dependency or something) that is not there.

This shows that it is very lickely not related to the rule, but binding/dependency/framework related.

Itā€™s odd that the problem is related to the binding/dependency/framework, keeping in mind @Seaside 's comment:

@lsiepel, did you install JRule on OH 4.2.0 and have the same problem?

Iā€™ll be able to check Sunday or Monday.

Downloaded the BETA21, dropped it in the addon folder and all seems fine:

2024-08-20 10:18:47.160 [INFO ] [on.jrule.internal.engine.JRuleEngine] - [JRuleEngine] Initializing Java Rule Engine with Separate Thread Executors min: 2 max: 10
2024-08-20 10:18:52.389 [INFO ] [tomation.jrule.internal.JRuleFactory] - [JRuleFactory] Initializing Java Rules Engine v4.0.0.202404081933
2024-08-20 10:18:52.390 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Initializing Start Initializing JRule Automation
2024-08-20 10:18:52.395 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Initializing JRule writing external Jars: /etc/openhab/automation/jrule/jar
2024-08-20 10:18:52.397 [INFO ] [.internal.compiler.JRuleJarExtractor] - [JRuleJar] Extracting jar: /etc/openhab/automation/jrule/jar/jrule.jar to: /etc/openhab/automation/jrule/jar/jrule.jar
2024-08-20 10:18:52.415 [INFO ] [.internal.compiler.JRuleJarExtractor] - [JRuleJar] Extracting jar: /etc/openhab/automation/jrule/jar/openhab-core.jar to: /etc/openhab/automation/jrule/jar/openhab-core.jar
2024-08-20 10:18:52.805 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Compiling generated sources
2024-08-20 10:18:58.374 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Creating jrule-generated.jar
2024-08-20 10:18:58.608 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] Compiling rules
2024-08-20 10:18:58.612 [WARN ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Found no java rules to compile and use in folder /etc/openhab/automation/jrule/rules/org/openhab/automation/jrule/rules/user/
2024-08-20 10:18:58.626 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Number of classes to load in to memory: 101 folder: /etc/openhab/automation/jrule/gen
2024-08-20 10:18:58.740 [INFO ] [.jrule.internal.handler.JRuleHandler] - Instantiated JRuleItems class
2024-08-20 10:18:58.743 [INFO ] [.jrule.internal.handler.JRuleHandler] - Instantiated JRuleThings class
2024-08-20 10:18:58.745 [INFO ] [.jrule.internal.handler.JRuleHandler] - Instantiated JRuleActions class
2024-08-20 10:18:58.746 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Found no classes to load into memory in folder: /etc/openhab/automation/jrule/rules
2024-08-20 10:18:58.747 [INFO ] [rule.internal.compiler.JRuleCompiler] - [JRuleCompiler] Found no user defined java rules to load into memory in folder: /etc/openhab/automation/jrule/rules-jar
2024-08-20 10:18:58.750 [INFO ] [.jrule.internal.handler.JRuleHandler] - [JRuleHandler] JRule Engine Initializing done! 
********   Loaded 0 rule classes, change 0
********   Loaded 0 rule methods, change 0
********   Loaded 0 item state triggers, change 0
********   Loaded 0 channel triggers, change 0
********   Loaded 0 timed triggers, change 0
********   Loaded 0 thing triggers, change 0

So now iā€™m confused, there must be something specific to your setup that prevents this rule addon to load correctly.

Note that i have no rules setup.

I guess we need to remove parts of your setup to determine the cause.
Do you have other addons installed? Could you list them and/or temporary uninstall them, to be sure there is not something else
Have you made any changes to configuration files in the userdata folder?

Huh, those are not good news :frowning:

Letā€™s start with the basics. I upgraded to OH 4.2.0 stable from 4.1.3 using dnf, as Iā€™ve done since 2.X.
OH runs with OpenJDK 64-Bit Server VM (Red_Hat-17.0.6.0.10-3.el9) (build 17.0.6+10-LTS) in a Raspberry Pi 4B (ARM64) / 4G RAM with CentOS 9 (64-bits).

I have the following add ons:

  • Astro
  • Netatmo
  • System Info
  • UniFi
  • Hue
  • OpenWeatherMap
  • Cloud Connector
  • Telegram
  • UPnP (Iā€™m not sure I had this one in 4.2.0, but itā€™s currently installed in 4.1.3)
  • iRobot
  • Sonos
  • TP-Link Smart Home
  • Roku
  • Mary Text-to-Speech

Manually installed:

  • TapoControl
  • Yale/August smart locks

For automation, I only use JRule and 1 or 2 old DSL rules that are not yet fully supported by JRule.

I guess I will have to run a clean installation of 4.2.0, install JRule first, and check. Iā€™ll try to do that this week.

@lsiepel, by this do you mean the /etc/openhab/ folder or /var/lib/openhab/config? I donā€™t think I have changed anything under /var/ā€¦

Hi, @lsiepel.

I upgraded from 4.1.3 to 4.2.1 and JRule loaded successfully. Maybe whatever was messed up with my configuration got fixed after I uninstalled OH and clean-installed 4.1.3.

Thank you for your help!