openhab-core icon indicating copy to clipboard operation
openhab-core copied to clipboard

Javascript rules compilation at openhab startup fails with error

Open yndtrud opened this issue 6 months ago • 0 comments

Community topic

OH: 4.3.0-4.3.5 JAVA: Zulu v17.58.21 CA-JDK v17.0.15 x64 OS: Windows Server 2022 Std Latest HW: ASUSPN41/IntelPentiumSilverN6000@2100/8GB_DDR4-2666/256GB_SSD-WD-GREEN JS: application/javascript ECMAScript 262 Edition 11

I encountered a problem with compiling javascript rules at system startup. Previously, when there was no forced compilation, there were no such problems with rules/scripts. DSL rules/scripts are compiled without problems.

In version 4.3.2 there was no problem, I could restart openhab. But in 4.3.0, 4.3.1, 4.3.4 and 4.3.5 a compilation error occurs.

My rules depend on other bindings (telegram, gsm modem, jdbc:postgresql[restoreOnStratup for date/string]), maybe this is a problem? If after starting manually (turn off and then turn on) the rule/script from the interface, then everything works.

2 rules, 1 script, three errors, everything is added via interface (not files), everything works correctly after recompilation (off/on from UI)

  1. rule: madhomebot - telegram bot (log, transforms, telegrams, jdbc(items history), state/post/send for items)
  2. rule: mobilesmsbot - sms bot (log, transforms, modem, jdbc(items history), state/post/send for items)
  3. script: javascript (there are no dependencies, temporarily adding different code for debugging, usually there is only this var log = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID); log.info('-JavaScript-'); and comments
2025-05-12 14:46:09.992 [INFO ] [org.openhab.core.Activator          ] - Starting openHAB 4.3.5 (Release Build)
2025-05-12 14:46:23.992 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'debug_sensor_climat_voltage.items'
2025-05-12 14:46:25.557 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'jdbc.persist'
2025-05-12 14:46:33.842 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2025-05-12 14:46:34.236 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'openhab.rules'
2025-05-12 14:46:38.136 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'intercom.rules'
2025-05-12 14:46:39.245 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rflnk.rules'
2025-05-12 14:46:44.087 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'socketplug.rules'
2025-05-12 14:46:45.834 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Timeout occurred when executing commandLine '[r:\servers\openhab\userdata\bin\arp-ping.exe, --help]'
2025-05-12 14:46:46.210 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Failed to execute commandLine '[arping, --help]'
2025-05-12 14:46:48.586 [WARN ] [.discovery.sddp.SddpDiscoveryService] - listenActiveScanUnicast() error 'Invalid argument: setsockopt'
2025-05-12 14:46:49.855 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'bluetooth.rules'
2025-05-12 14:46:50.158 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'lightbulb.rules'
2025-05-12 14:46:51.977 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'relay.rules'
2025-05-12 14:46:52.916 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'debug.rules'
2025-05-12 14:46:53.690 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'siren.rules'
2025-05-12 14:46:55.238 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'weather.rules'
2025-05-12 14:46:55.785 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'intrusion.rules'
2025-05-12 14:46:55.862 [INFO ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: Driver is available::Yank setupDataSource
2025-05-12 14:47:02.461 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'alarms.rules'
2025-05-12 14:47:03.171 [INFO ] [ab.ui.habpanel.internal.HABPanelTile] - Started HABPanel at /habpanel
2025-05-12 14:47:24.042 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'voice.rules'
2025-05-12 14:47:24.584 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script: Error: Failed to get any services of type(s): org.openhab.core.thing.link.ItemChannelLinkRegistry
        at <js>.getService(@openhab-globals.js:2)
        at <js>.236(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        at <js>.605(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        ... 28 more
2025-05-12 14:47:24.823 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script: Error: Failed to get any services of type(s): org.openhab.core.thing.link.ItemChannelLinkRegistry
        at <js>.getService(@openhab-globals.js:2)
        at <js>.236(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        at <js>.605(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        ... 28 more
2025-05-12 14:47:25.037 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script: Error: Failed to get any services of type(s): org.openhab.core.thing.link.ItemChannelLinkRegistry
        at <js>.getService(@openhab-globals.js:2)
        at <js>.236(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        at <js>.605(@openhab-globals.js:2)
        at <js>.o(@openhab-globals.js:2)
        ... 28 more
2025-05-12 14:47:38.204 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'network.rules'
2025-05-12 14:47:42.265 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'scenes.rules'
2025-05-12 14:48:15.419 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online
2025-05-12 14:48:20.292 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid openhab
2025-05-12 14:48:33.375 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to compile rule ‘madhomebot' with status 'UNINITIALIZED'
2025-05-12 14:48:33.381 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to compile rule ‘mobilesmsbot' with status 'UNINITIALIZED'
2025-05-12 14:48:33.388 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to compile rule ‘javascript' with status 'UNINITIALIZED'
2025-05-12 14:48:33.397 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started.

yndtrud avatar May 16 '25 10:05 yndtrud