openHAB 4.0 SNAPSHOT discussion

Upgraded to #3313 and all rules are broken. There appears to be up to three separate problems.

Problem 1

The first seems to be a problem with the addon.xml file for the Zigbee binding.

20│--------------------------------------------- file got truncated /srv/openhab/userdata/logs/openhab.log 2023/02/14 07:56:04---------------------------------------------│
20│2023-02-14 07:56:11.707 [INFO ] [org.openhab.core.Activator          ] - Starting openHAB 4.0.0 (build Build #3313)                                                     │
20│2023-02-14 07:56:12.501 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'America/Denver'.                                                             │
20│2023-02-14 07:56:12.516 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to 'X,Y'.                                      │
20│2023-02-14 07:56:12.517 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'en_US'.                                                                         │
20│2023-02-14 07:56:12.518 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Measurement system set to 'US'.                                                                │
20│2023-02-14 07:56:19.406 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.items'                                                                     │
20│2023-02-14 07:56:20.031 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'                                                                  │
20│2023-02-14 07:56:20.098 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'                                                                  │
20│2023-02-14 07:56:28.775 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007                                    │
20│2023-02-14 07:56:34.019 [WARN ] [ty.util.ssl.SslContextFactory.config] - Trusting all certificates configured for Client@581281f4[provider=null,keyStore=null,trustStore│
20│=null]                                                                                                                                                                  │
20│2023-02-14 07:56:34.020 [WARN ] [ty.util.ssl.SslContextFactory.config] - No Client EndPointIdentificationAlgorithm configured for Client@581281f4[provider=null,keyStore│is.g│=null,trustStore=null]                                                                                                                                                  │
00│2023-02-14 07:56:34.036 [WARN ] [core.thing.internal.ThingManagerImpl] - No config description for 'channel-type:http:channel-config-switch' found when normalizing conf│5920│iguration for 'http:url:adguard:protection_status'. This is probably a bug.                                                                                             │
20│2023-02-14 07:56:34.100 [INFO ] [nding.http.internal.HttpThingHandler] - Using the insecure client for thing 'http:url:adguard'.                                        │
20│2023-02-14 07:56:34.456 [INFO ] [.network.internal.utils.NetworkUtils] - CIDR prefix is smaller than /24 on interface with address 172.17.0.1/16, truncating to /24, som│
20│e addresses might be lost                                                                                                                                               │
20│2023-02-14 07:56:36.764 [INFO ] [nternal.manager.ShellyManagerServlet] - Shelly Manager started at http(s)://10.10.1.112:8080/shelly/manager                            │
20│2023-02-14 07:56:37.017 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'argus.koshak.lan' with clientid openhab                    │
20│2023-02-14 07:56:37.240 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/OH-INF/addon/addon.xml' in module 'org.openhab.binding.zigbee' could not be │
20│parsed:                                                                                                                                                                 │
20│---- Debugging information ----                                                                                                                                         │
20│cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException                                                                                       │
20│cause-message       : author                                                                                                                                            │
20│class               : java.util.ArrayList                                                                                                                               │
20│required-type       : java.util.ArrayList                                                                                                                               │
20│converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter                                                                               │
20│path                : /addon/author                                                                                                                                     │
20│line number         : 10                                                                                                                                                │
20│class[1]            : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│required-type[1]    : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│converter-type[1]   : org.openhab.core.addon.xml.internal.AddonInfoConverter                                                                                            │
20│version             : 1.4.19                                                                                                                                            │
20│-------------------------------                                                                                                                                         │
20│com.thoughtworks.xstream.converters.ConversionException:                                                                                                                │
20│---- Debugging information ----                                                                                                                                         │is.g│cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException                                                                                       │
20│cause-message       : author                                                                                                                                            │
20│class               : java.util.ArrayList                                                                                                                               │
20│required-type       : java.util.ArrayList                                                                                                                               │
20│converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter                                                                               │is.g│path                : /addon/author                                                                                                                                     │
20│line number         : 10                                                                                                                                                │
20│class[1]            : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│required-type[1]    : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│converter-type[1]   : org.openhab.core.addon.xml.internal.AddonInfoConverter                                                                                            │
20│version             : 1.4.19                                                                                                                                            │
20│-------------------------------                                                                                                                                         │
00│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:81) ~[bundleFile:1.4.19]                                                        │1020│        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52) ~[bundleFile:1.4.19]                                                 │
20│        at org.openhab.core.addon.xml.internal.AddonInfoConverter.unmarshal(AddonInfoConverter.java:77) ~[?:?]                                                          │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74) ~[bundleFile:1.4.19]                                                        │
20│        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32) ~[bundleFile:1.4.19]                        │
20│        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1421) ~[bundleFile:1.4.19]                                                                           │
20│        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1399) ~[bundleFile:1.4.19]                                                                           │
20│        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1350) ~[bundleFile:1.4.19]                                                                             │
20│        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1304) ~[bundleFile:1.4.19]                                                                             │
20│        at org.openhab.core.config.xml.util.XmlDocumentReader.readFromXML(XmlDocumentReader.java:105) ~[bundleFile:?]                                                   │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:396) [bundleFile:?]                                   │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:382) [bundleFile:?]                                    │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:347) [bundleFile:?]                                            │  
.g│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │is.g│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: author                                                                                          │
20│        at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:81) ~[bundleFile:1.4.19]                                                          │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55) ~[bundleFile:1.4.19]                                                │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88) ~[bundleFile:1.4.19]                                          │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79) ~[bundleFile:1.4.19]                                              │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │is.g│        at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74) ~[bundleFile:1.4.19]                                                              │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
00│        at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71) ~[bundleFile:1.4.19]                                                        │3320│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47) ~[bundleFile:1.4.19]                                                          │
20│        at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29) ~[bundleFile:1.4.19]                                       │
20│        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:131) ~[bundleFile:1.4.19]          │
20│        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117) ~[bundleFile:1.4.19]              │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:99) ~[bundleFile:1.4.19]          │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:92) ~[bundleFile:1.4.19]                     │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:86) ~[bundleFile:1.4.19]                     │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:81) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74) ~[bundleFile:1.4.19]                                                        │
20│        ... 24 more                                                                                                                                                     │

The Zwave binding has a similar error.

Problem 2

The second problem is related to creating the script engine.

20│2023-02-14 07:56:38.495 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/node_modules/openhab/@globals-webpack.config.j│
20│s'                                                                                                                                                                      │
20│2023-02-14 07:56:39.006 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = d0...e1, base URL = http://localhost:8080)      │is.g│2023-02-14 07:56:43.934 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error while creating ScriptEngine                                                              │
20│org.graalvm.polyglot.PolyglotException: Cannot invoke "java.nio.file.Path.resolve(java.nio.file.Path)" because the return value of "java.nio.file.Path.getRoot()" is nul│
20│l                                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.isRootNodePath(OpenhabGraalJSScriptEngine.java:312) ~[?:?]                            │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine$1.checkAccess(OpenhabGraalJSScriptEngine.java:190) ~[?:?]                             │is.g│        at com.oracle.truffle.api.TruffleFile.checkAccess(TruffleFile.java:2125) ~[?:?]                                                                                 │
20│        at com.oracle.truffle.api.TruffleFile.exists(TruffleFile.java:288) ~[?:?]                                                                                       │
20│        at com.oracle.truffle.js.runtime.JSRealm.addCommonJSGlobals(JSRealm.java:1617) ~[?:?]                                                                           │
20│        at com.oracle.truffle.js.runtime.JSRealm.addOptionalGlobals(JSRealm.java:1692) ~[?:?]                                                                           │
20│        at com.oracle.truffle.js.runtime.JSRealm.initialize(JSRealm.java:2193) ~[?:?]                                                                                   │
20│        at com.oracle.truffle.js.lang.JavaScriptLanguage.initializeContext(JavaScriptLanguage.java:362) ~[?:?]                                                          │is.g│        at com.oracle.truffle.js.lang.JavaScriptLanguage.initializeContext(JavaScriptLanguage.java:114) ~[?:?]                                                          │
20│        at com.oracle.truffle.api.TruffleLanguage$Env.postInit(TruffleLanguage.java:3317) ~[?:?]                                                                        │
00│        at com.oracle.truffle.api.LanguageAccessor$LanguageImpl.postInitEnv(LanguageAccessor.java:289) ~[?:?]                                                           │0920│        at com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureInitialized(PolyglotLanguageContext.java:689) ~[?:?]                                               │
20│        at com.oracle.truffle.polyglot.PolyglotContextImpl.eval(PolyglotContextImpl.java:1294) ~[?:?]                                                                   │
20│        at com.oracle.truffle.polyglot.PolyglotContextDispatch.eval(PolyglotContextDispatch.java:63) ~[?:?]                                                             │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.evalInternal(GraalJSScriptEngine.java:376) ~[?:?]                                                     │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.initGlobal(GraalJSBindings.java:96) ~[?:?]                                                                │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.initContext(GraalJSBindings.java:92) ~[?:?]                                                               │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.requireContext(GraalJSBindings.java:86) ~[?:?]                                                            │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.put(GraalJSBindings.java:129) ~[?:?]                                                                      │
20│        at javax.script.SimpleScriptContext.setAttribute(SimpleScriptContext.java:246) ~[java.scripting:?]                                                              │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.addAttributeToScriptContext(ScriptEngineManagerImpl.java:286) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.createScriptEngine(ScriptEngineManagerImpl.java:156) ~[?:?]                       │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:328) ~[?:?]              │9.78│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:306) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │is

This error repeats for every file in $OH_CONF/automation/js

Problem 3 (may be another symptom of Problem 2)

Several of my rules are throwing this error:

20│2023-02-14 07:56:43.958 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'debounce4': Cannot invoke "java.util.Map.put(Object, Object)" because "│
.g│this.global" is null                                                                                                                                                    │

It seems reasonable that this error is caused by problem 2 failing to load and/or initialize something (cache perhaps?).

Your first issue is related to Remove author from addon xsd by kaikreuzer · Pull Request #3362 · openhab/openhab-core · GitHub or more specifically to the failed zigbee and zwave builds over the last few days: https://ci.openhab.org

I believe second and third issue are the same. I encountered the same today and while debugging the first one (Cannot invoke "java.nio.file.Path.resolve(java.nio.file.Path)" because the return value of "java.nio.file.Path.getRoot()" is null) I found in the debugger that this.global is null when setting the engine identifier in the script context. I’m still not sure what the root cause is.

2 Likes

I guessed it had to do with that PR. I created an issue on Zigbee [The XML document '/OH-INF/addon/addon.xml' in module 'org.openhab.binding.zigbee' could not be parsed · Issue #797 · openhab/org.openhab.binding.zigbee · GitHub] and was about to open on on zwave. Is that premature and should I close it, or go ahead and open one for Zwave too? I went ahead and closed it.

As I’m understanding it, the bindings already have a fix for this and once the builds work the problem will be solved.

Thankfully it doesn’t appear to prevent the bindings from working.

Let me know if there is any additional information or tests I can provide to help diagnosing the second two problems. Because it’s a loading file problem I immediately started wondering if those file watcher PRs that have recently been merged are the culprit.

I have created Fix build by J-N-K · Pull Request #1847 · openhab/org.openhab.binding.zwave · GitHub and Fix build by J-N-K · Pull Request #798 · openhab/org.openhab.binding.zigbee · GitHub to fix the build issues.

1 Like

I opened the below issue related to this. This seems to me to be related to the jsscripting addon more than being a core issue but I could be wrong.

Hurray! The builds completed! :partying_face:

Yep, and I have also already built a new distro from it! Build #3314 should have the new versions included.

1 Like

I can confirm, build #3314 fixes author problem in the addon.xml file from openHAB 4.0 SNAPSHOT discussion - #166 by rlkoshak as well as the Zigbee Channel ID problem reported in openHAB 4.0 SNAPSHOT discussion - #106 by rlkoshak.

Looking better! I hope the file.Path problem is this easy to find and fix too.

And I learned where to look to see when the last build was. :smiley:

Thanks everyone!

Unfortunately it’s not so easy. The issue seems to be the relative/absolute path, but I don’t know what is expected, so it’s hard to fix. Maybe @florian-h05, @digitaldan or @jpg0 can answer that.

If my absolute path to the the nodes_modules is /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules, what are isRootNodePath and nodeFileToResource(Path path) expected to return for the directory /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules and the file /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules/pingilib/index.js?

@digitaldan authored this in [jsscripting] Support non unix file paths by digitaldan · Pull Request #11805 · openhab/openhab-addons · GitHub. This was before my time as JS Scripting contributor, but reading through the PR and the linked issue I understand the purpose. I can provide you more information tomorrow.

Other JS issues will be fixed by [jsscripting] Fix node_modules handling by J-N-K · Pull Request #14398 · openhab/openhab-addons · GitHub

2 Likes

I just updated to SNAPSHOT #3323 which, if I’m reading Jenkens right is 10 hours old, so it should contain the fixes for [jsscripting] Fix node_modules handling by J-N-K · Pull Request #14398 · openhab/openhab-addons · GitHub (and the related fix for core).

Unfortunately, I’m still seeing some new errors. I tried it both with openhab-js installed via npm and using the version that comes with the add-on.

  │2023-02-20 10:04:16.400 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
  │org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: 'path'                                                                                  │
  │        at com.oracle.truffle.polyglot.PolyglotMapAndFunction.apply(PolyglotMapAndFunction.java:46) ~[?:?]                                                              │
  │        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$11(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                 │
  │        at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]                                                                                                       │
  │        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$9(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                  │
  │        at <js>.:program(@globals-webpack.config.js:1) ~[?:?]                                                                                                           │
  │        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │
  │        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
  │        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │
  │        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │
  │        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
  │e.java:58) ~[?:?]                                                                                                                                                       │
  │        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
Ca│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
00│e.java:58) ~[?:?]                                                                                                                                                       │42
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:16.589 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/@globals-webpack.conf│
20│ig.js': org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: 'path'                                                                          │
20│2023-02-20 10:04:16.595 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/@globals-webpack.co│
20│nfig.js'                                                                                                                                                                │
Ca│2023-02-20 10:04:16.684 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/openhab-js/@openhab-globals.js'               │
2

...

  │2023-02-20 10:04:41.123 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
Ca│org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: './index'                                                                               │
20│        at com.oracle.truffle.polyglot.PolyglotMapAndFunction.apply(PolyglotMapAndFunction.java:46) ~[?:?]                                                              │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$11(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                 │
20│        at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$9(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                  │
20│        at <js>.:anonymous(@openhab-globals.js:5) ~[?:?]                                                                                                                │la
rm│        at <js>.:program(@openhab-globals.js:3) ~[?:?]                                                                                                                  │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │la
rm│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │la
rm│        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
00│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│17
20│e.java:58) ~[?:?]                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:41.138 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/@openhab-globals.js':│
20│ org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: './index'                                                                              │
20│2023-02-20 10:04:41.138 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/@openhab-globals.js│
20│'                                                                                                                                                                       │
20│2023-02-20 10:04:41.149 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/openhab-js/test/@runtime.mock.js'             │  

And so on. I’m not seeing the error talking about global not being defined at least so that’s progress.

Not all the errors are exactly the same. Most of them are the “TypeError: Cannot load CommonJS module” but I’m also seeing stuff like

rm│2023-02-20 10:04:51.979 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
20│org.graalvm.polyglot.PolyglotException: ReferenceError: "jest" is not defined                                                                                           │la
rm│        at <js>.:program(cache.spec.js:1) ~[?:?]                                                                                                                        │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │la
rm│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │
20│        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
00│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │22
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:51.984 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/test/cache.spec.js': │
20│org.graalvm.polyglot.PolyglotException: ReferenceError: "jest" is not defined                                                                                           │
20│2023-02-20 10:04:51.984 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/test/cache.spec.js'│

There are tons of these but a lot of them seem to be coming from the unit tests.

However, once everything settles, the rules appear to work without error. So the errors are more alarming than a problem, though I do need to remember to manually run my System runlevel reached rules by hand after a restart. :partying_face:

I can’t reproduce that, sorry.

I can’t reproduce as well (at least I had no errors on my dev system).
Reading through your stack traces, I wonder what is happening. It seems like the addon is trying to load some library files as script (e.g. the ReferenceError for jest in cache.spec.js: this are our unit tests).

Which platform are you on?

Those logs come from:

  • OH 4.0 SNAPSHOT #3323
  • using the openhab-js that comes with the add-on, not installed via npm
  • for some reason, when I npm remove openhab it leaves behind @js-joda behind and I didn’t remove it
  • openhab_rules_tools and a personal library remains installed in node_modules
  • the OS is the official Docker container running on an Ubuntu 20.04 VM with userdata and cache folders on the host mounted into the container as volumes

I’ve done a couple of restarts with the above configuration and I get those errors every time, but once everything settles down my rules work just fine. I’ve been able to verify that the runlevel triggered rules are even triggering and successfully running as expected.

Maybe that (re)loading script is successful?

The paths reported in the exception are correct given the way the Docker container is configured. It’s a manual style install to /openhab so conf is equivalent to /etc/openhab on a apt/yum installed OH.

I haven’t gone through and counted but it looks like I get at least one error per file in openhab-js.

I’m happy to provide a full log or any other additional information. I’m about to test it with openhab-js installed via npm to see if anything changes. Will report back soon. Identical behavior.

As I scroll through the logs, I’m noticing that the error seems to always come from when a .js file is loading another one using a relative path:

  │2023-02-20 11:36:20.546 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/items/item-history.js│
  │': org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: '../time'

  │2023-02-20 11:36:23.282 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/openhab-js/items/metadata/itemchannellink.js' │
20│2023-02-20 11:36:24.706 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │ra
al│org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: '../../osgi'

Can you share a very basic example of a rule that causes this behavior? Thanks.

The challenge is I can’t tell which, if any rules these errors are coming from. The errors only occur during OH startup. The errors do not mention any rule or script action or anything like that. Just “Failed to execute script:”.

I’ll try some experiments to see if I can narrow down the behavior to a specific rule.

Test Results
disabled all rules With all rules and scripts disabled the errors still occur.
removed the automation jsondb file(s) so there are no rules even in the system With absolutely no rules in the config at all the errors still occur.

It’s not caused by a rule. It’s something more fundamental than that.

It happens on a system without ANY JS rules?

Yes. I completely deleted automation_rules.json , automation_rules_disabled.json (just for good measure) and all the backups (lesson learned from above). I also confirmed that no rules were listed under Rules and Scripts in MainUI (I don’t have Scenes or Schedule rules). The errors still occurred.

It seems merely having the add-on installed is enough to cause these errors for me.

Reading your logs again, I think there is no problem with the addon. It works as supposed.

The problem seems to be, that you have the openhab-js library inside your automation/js directory, it should not be there. It’s a npm module and should be in the automation/js/node_modules folder, but never in automation/js. I wonder how it ended up there.

Can you please remove that automation/js/openhab-js folder?