Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Fails on latest OH 3.0.0 #19

Open
simonihmig opened this issue Dec 23, 2020 · 5 comments
Open

Fails on latest OH 3.0.0 #19

simonihmig opened this issue Dec 23, 2020 · 5 comments

Comments

@simonihmig
Copy link
Contributor

I tried to get your latest 3.0.0 snapshot of the scripting addon running with my existing scripts. I updated ohj to the latest commit on master.

Still getting this exception:

14:01:08.144 [WARN ] [g.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.
14:01:10.003 [WARN ] [script.js.osgi                       ] - bc=undefined		[osgi at source <unknown>, line 53]
14:01:10.032 [WARN ] [script.js.osgi                       ] - Failed to get service org.openhab.core.items.MetadataRegistry: [object Error]		[osgi at source <unknown>, line 53]
14:01:10.050 [WARN ] [script.js.osgi                       ] - Failed to get service org.eclipse.smarthome.core.items.MetadataRegistry: [object Error]		[osgi at source <unknown>, line 53]
14:01:10.108 [ERROR] [ab.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: Error: Failed to get any services of type(s): org.openhab.core.items.MetadataRegistry,org.eclipse.smarthome.core.items.MetadataRegistry
	at <js>.getService(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/osgi.js:72) ~[?:?]
	at <js>.:anonymous(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/metadata/metadata.js:13) ~[?:?]
	at <js>.:anonymous(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/items/managed.js:6) ~[?:?]
	at <js>.:anonymous(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/items/items.js:8) ~[?:?]
	at <js>.:anonymous(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/rules.js:11) ~[?:?]
	at <js>.get rules(/openhab/conf/automation/lib/javascript/personal/node_modules/ohj/index.js:13) ~[?:?]
	at <js>.:program(<eval>:1) ~[?:?]
	at org.graalvm.polyglot.Context.eval(Context.java:345) ~[?:?]
	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:379) ~[?:?]
	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:343) ~[?:?]
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) ~[java.scripting:?]
	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocable.eval(DelegatingScriptEngineWithInvocable.java:51) ~[bundleFile:?]
	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocable.eval(InvocationInterceptingScriptEngineWithInvocable.java:78) ~[bundleFile:?]
	at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocable.eval(DelegatingScriptEngineWithInvocable.java:51) ~[bundleFile:?]
	at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocable.eval(InvocationInterceptingScriptEngineWithInvocable.java:78) [bundleFile:?]
	at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:170) [bundleFile:?]
	at org.openhab.core.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.importFile(ScriptFileWatcher.java:191) [bundleFile:?]
	at org.openhab.core.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.processWatchEvent(ScriptFileWatcher.java:157) [bundleFile:?]
	at org.openhab.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:322) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]

Note that the logged bundleContext is undefined!

Is it working for you (I assume that looking at your oh-config repo), and if so, what did I miss?

@jpg0
Copy link
Owner

jpg0 commented Dec 23, 2020

Thanks for the report! I have actually not got all of ohj working on OH3 yet - just because I was prioritising getting the core plugin to work (and getting lots merged into OH core, meaning the plugin is much simpler now, even if not yet bundled). I did start looking at it in depth yesterday though; I think it's a case of going through and updating references to relocated/refactored code in OH3. I'm doing this at the moment though (well, when I have time), so expect to get this working soon.

@jpg0
Copy link
Owner

jpg0 commented Dec 28, 2020

Do you have the ohj-support addon installed? I moved supporting things into this plugin so that I could get the foundational JS support into OH without these bits.

Someone else fixed it temporarily, but I'm still not sure why it's broken: jpg0/oh-config#2 (comment)

@jpg0
Copy link
Owner

jpg0 commented Dec 28, 2020

Also: OH3 seems pretty broken regarding script startup: scripts are loaded too early (before all the system is up) and also they are not ordered. I am waiting for these to be fixed before I migrate myself.

@simonihmig
Copy link
Contributor Author

I got it basically working, see jpg0/oh-config#2 (comment)

Leaving this open for now as the published ohj version still does not work ootb...

@moonraker46
Copy link

Is there a existing jar for OH3.x ?

The one mentioned in https://www.npmjs.com/package/ohj is a) broken and b) for OH2.5.

Thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants