Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/javascript/personal/HelloWorld.js': java.lang.ClassNotFoundException: org.openhab.core.automation.util.RuleBuilder
@jvank, I’m guessing you are using 2.4 or 2.5M1. When using the new rule engine, it is best to use a recent snapshot version of OH. If you don’t want to upgrade, replace lines 16 and 17 of core.utils.js…
var RuleBuilder = Java.type("org.openhab.core.automation.util.RuleBuilder");
var RuleManager = Java.type("org.openhab.core.automation.RuleManager");
… with this…
try {
var RuleBuilder = Java.type("org.openhab.core.automation.util.RuleBuilder");
} catch(e) {
var RuleBuilder = Java.type("org.eclipse.smarthome.automation.core.util.RuleBuilder");
}
try {
var RuleManager = Java.type("org.openhab.core.automation.RuleManager");
} catch(e) {
var RuleManager = Java.type("org.eclipse.smarthome.automation.RuleManager");
}
It appears the JS helper libraries are using the newer (post ESH reintegration) package names for some of the classes. There may be others, but I’ll put in a PR for this. You wouldn’t have had this issue with Jython .
Thanks for the tips! Sadly they didn’t fix my problem.
I tried changing the lines as you mentioned, but i still had the same issue. I have now upgraded to snapshot via openhabian-config, but I still have pretty much the same issue. I do get some more stuff in the log now:
When openhab is loading is see the 30s delay, as expected, then it gives me these messages:
2019-06-27 15:12:58.132 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'javascript/personal/HelloWorld.js'
2019-06-27 15:12:58.213 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'js' with identifier: file:/etc/openhab2/automation/jsr223/javascript/personal/HelloWorld.js
2019-06-27 15:12:58.590 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/javascript/personal/HelloWorld.js': java.lang.ClassNotFoundException: org.eclipse.smarthome.automation.core.util.RuleManager
2019-06-27 15:12:58.591 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: javascript/personal/HelloWorld.js
I still dont get this, because it says it’s loaded the script, but it still doesn’t work…
What can I do to fix this?
And yes, I get that jython may be better, but I want to learn both anyways so I’ll get to that one time
Greetings,
jvank
PS: Since the upgrade to snapshot, I get this in my logs every minute:
Sorry, I went too fast and messed up a copy/paste… I’ve corrected my post. Try that out ! Or grab the latest from the repo, as this is now included.
Either that is a recent issue, or it may be a symptom of not clearing the cache after upgrading. Also, try restarting OH an additional time… OH does not seem to be starting up properly the first time after the cache has been cleared.
I tried it, and this time it worked right away. Thanks!
I also found out that the install failed log entry could be solved by removing restdocs from addons.config
Thanks for your help and now it’s time for me to start learning how to use this stuff!
Hi, and thanks again for following me
I’m basically following this old project where Phyton and Javascript scripts were availables in download and are packet ready
My change was to restructuring the automation and Libraries based on the new approach (the suggest you just referring to)
Those are very out of date and specify OH 2.4.0. Maybe @illnesse can update them or help you out (the readme says to file an issue or to hit him up in the other topic). Although, he migrated to the libraries that I maintain…