No, I am using an older version of those. But I carefully compared the code and it is equivalent.
All examples - whether jython or javascript - pass org.joda.time.DateTime to ScriptExecution.createTimer. createTimer however expects org.joda.time.base.AbstractInstant
According to the information I found AbstractInstant is a base class of DateTime and as such an explicit cast should not be needed.
I created a bare bone example and checked it against the reference implementation you linked:
var ScriptExecution = Java.type("org.eclipse.smarthome.model.script.actions.ScriptExecution");
var DateTime = Java.type("org.joda.time.DateTime");
ScriptExecution.createTimer(DateTime.now().plusSeconds(1), function () { logError("Called"); });
results in
2019-09-08 03:42:50.007 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/dimmers.js': Cannot cast org.joda.time.DateTime to org.joda.time.base.AbstractInstant
The only change I can remember actually was to stop openhab, clear cache and temp and reboot openhabian.
Pretty late now, need some sleep. I’ll stop openhab tomorrow and clear cache and tmp again and restart and try again. The only extra on top of stock 2.4 openhabian is a 2.5 zwave binding which requires to install (feature:install) a new serial library. Want to exclude this as a cause.
Thanks a lot for all the support.
No prob… I really really doubt the zwave binding would cause an issue here. Check your Java version.
This works for me too…
'use strict';
var log = Java.type("org.slf4j.LoggerFactory").getLogger("jsr223.javascript.TEST");
var ScriptExecution = Java.type("org.eclipse.smarthome.model.script.actions.ScriptExecution");
var DateTime = Java.type("org.joda.time.DateTime");
ScriptExecution.createTimer(DateTime.now().plusSeconds(1), function () { log.debug("Called"); });
The error seems to be caused by openhab stable 2.4.0 on openhabian.
I have now upgraded to the latest snapshot using openhabian-config.
Problem solved.
Needed to fix some issues in my scripts. Hope to migrate to current helper libraries soon.
A big thanks to @5iver and @rossko57 for their support.