Hi,
I’m trying to get the jsr223 binding working working with the built in javascript engine. I installed the package from the apt repo and added the missing jsr223engine.xml to the OSGI-INF directory of the jar file. I also added -Dorg.osgi.framework.bundle.parent=ext to my java options.
The binding is starting up and looking for scripts, however it throws an error when loading my test script:
2015-10-06 21:24:45.026 [INFO ] [o.c.j.i.e.scriptmanager.Script] - Loading Script test_rules.js
2015-10-06 21:24:45.041 [ERROR] [o.o.c.j.i.e.s.ScriptManager ] - script exception
javax.script.ScriptException: sun.org.mozilla.javascript.EcmaError: TypeError: sun.org.mozilla.javascript.NativeJavaObject@60f6e0a8 is not a function, it is object. (<Unknown source>#5) in <Unknown source> at line number 5
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224) ~[na:1.7.0_79]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) ~[na:1.7.0_79]
at org.openhab.core.jsr223.internal.engine.scriptmanager.Script.loadScript(Script.java:79) ~[bundlefile:na]
at org.openhab.core.jsr223.internal.engine.scriptmanager.Script.<init>(Script.java:67) ~[bundlefile:na]
at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.loadScript(ScriptManager.java:86) [bundlefile:na]
at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.scriptsChanged(ScriptManager.java:166) [bundlefile:na]
at org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptUpdateWatcher.run(ScriptUpdateWatcher.java:104) [bundlefile:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: sun.org.mozilla.javascript.EcmaError: TypeError: sun.org.mozilla.javascript.NativeJavaObject@60f6e0a8 is not a function, it is object. (<Unknown source>#5)
at sun.org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687) ~[na:1.7R4]
at sun.org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665) ~[na:1.7R4]
at sun.org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693) ~[na:1.7R4]
at sun.org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3712) ~[na:1.7R4]
at sun.org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3767) ~[na:1.7R4]
at sun.org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3755) ~[na:1.7R4]
at sun.org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1505) ~[na:1.7R4]
at sun.org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815) ~[na:1.7R4]
at sun.org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109) ~[na:1.7R4]
at sun.org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394) ~[na:1.7R4]
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116) ~[na:1.7.0_79]
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109) ~[na:1.7.0_79]
at sun.org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091) ~[na:1.7R4]
at sun.org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:120) ~[na:1.7R4]
at sun.org.mozilla.javascript.Context.evaluateReader(Context.java:1110) ~[na:1.7R4]
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214) ~[na:1.7.0_79]
... 7 common frames omitted
The test_rules.js script is as follows:
'use strict';
var jsTest = new Rule(){
getEventTrigger: function(){
oh.logDebug("getEventTrigger", "self:"+this);
return [
new TimerTrigger("0/15 * * * * ?")
];
},
execute: function(event){
oh.logError("Hello from javascript");
}
};
function getRules(){return new RuleSet([jsTest]);}
Any help appreciated!
Thanks in advance.