Nothing didn’t work
Now Im do everything as written in tutorial but they do not work also HelloWorld.js do not write into log every 10 seconds…
First Im enable logging:
jsr223 │ DEBUG
org.openhab.core.automation │ DEBUG
Then Im shutdown openhab and copy files.
Im copy content of Core folder into openhab:
Then Im rename configuration file:
And copy demo script to personal folder:
Then Im start openhab and log:tail
19:01:09.577 [INFO ] [b.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Ljubljana'.
19:01:09.610 [INFO ] [b.core.internal.i18n.I18nProviderImpl] - Location set to 'REMOVED'.
19:01:09.620 [INFO ] [b.core.internal.i18n.I18nProviderImpl] - Locale set to 'sl_SI'.
19:01:11.028 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for Oracle Nashorn (11.0.9): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
19:01:11.038 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (11.0.9): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
19:01:16.938 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring REMOVED
19:01:25.739 [DEBUG] [ovider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation'
19:01:25.739 [DEBUG] [ovider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation.module.script.rulesupport'
19:01:25.870 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added CoreModuleHandlerFactory
19:01:25.870 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added TimerModuleHandlerFactory
19:01:25.878 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptModuleHandlerFactory
19:01:25.880 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedCustomModuleHandlerFactory
19:01:25.880 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedPrivateModuleHandlerFactory
19:01:25.880 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedActionModuleTypeProvider
19:01:25.880 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedThingActionModuleTypeProvider
19:01:25.880 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added EphemerisModuleHandlerFactory
19:01:28.624 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for null (null): supports Rule DSL (v1) with file extensions null, names null, and mimetypes [application/vnd.openhab.dsl.rule]
19:01:28.635 [INFO ] [b.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
19:01:31.389 [DEBUG] [re.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added MediaModuleHandlerFactory
19:01:31.481 [INFO ] [org.openhab.ui.internal.UIService ] - Started UI on port 8080
19:01:31.974 [INFO ] [hab.ui.habpanel.internal.HABPanelTile] - Started HABPanel at /habpanel
19:01:32.148 [DEBUG] [io.openhabcloud.internal.CloudService] - openHAB Cloud connector activated
19:01:32.148 [DEBUG] [io.openhabcloud.internal.CloudService] - remoteAccessEnabled is not set, keeping value 'true'
19:01:32.157 [DEBUG] [io.openhabcloud.internal.CloudService] - API Token = REMOVED
19:01:32.167 [DEBUG] [io.openhabcloud.internal.CloudService] - Using secret at 'c:\openhab\userdata\openhabcloud\secret' with content 'REMOVED'
19:01:32.167 [DEBUG] [io.openhabcloud.internal.CloudService] - UUID = REMOVED, secret = REMOVED
19:01:32.179 [DEBUG] [io.openhabcloud.internal.CloudService] - Using secret at 'c:\openhab\userdata\openhabcloud\secret' with content 'REMOVED'
19:01:33.378 [DEBUG] [.io.openhabcloud.internal.CloudClient] - Socket.IO connected
19:01:33.378 [INFO ] [.io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = REMOVED, base URL = http://localhost:8080)
If I create simple Script in UI and run it:
var OPENHAB_CONF = Java.type('java.lang.System').getenv('OPENHAB_CONF');
load(OPENHAB_CONF + '/automation/lib/javascript/core/actions.js');
if (Ping.checkVitality("10.5.5.5", 0, 5000)) {
LogAction.logInfo("Rules", "Server is online");
} else {
LogAction.logInfo("Rules", "Server is offline");
}
It still crash:
19:16:16.416 [INFO ] [smarthome.event.RuleUpdatedEvent ] - Rule '71a2abce18' has been updated.
19:16:23.261 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'application/javascript' with identifier: 9f0e7e1f-6265-444d-98c0-eeb15f4de628
19:16:23.715 [WARN ] [re.automation.internal.RuleEngineImpl] - Fail to execute action: script
java.lang.RuntimeException: java.lang.ClassNotFoundException: org.eclipse.smarthome.model.script.actions.Exec cannot be found by org.apache.aries.jax.rs.whiteboard_1.0.9
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:531) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.Context.evaluateSource(Context.java:1438) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.Context.load(Context.java:962) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.Global.load(Global.java:1720) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$37$\^eval\_$cu1$restOf/0x00000007c0dfd040.:program(<eval>:2) ~[?:?]
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:162) ~[jdk.scripting.nashorn:?]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) ~[java.scripting:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) ~[?:?]
at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1179) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1031) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1047) [bundleFile:?]
at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:305) [bundleFile:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) [bundleFile:1.0.9]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) [bundleFile:1.0.9]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) [bundleFile:1.0.9]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) [bundleFile:1.0.9]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) [bundleFile:1.0.9]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) [bundleFile:1.0.9]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [bundleFile:1.0.9]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [bundleFile:1.0.9]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [bundleFile:1.0.9]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220) [bundleFile:1.0.9]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [bundleFile:3.1.0]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) [bundleFile:1.0.9]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.ClassNotFoundException: org.eclipse.smarthome.model.script.actions.Exec cannot be found by org.apache.aries.jax.rs.whiteboard_1.0.9
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150) ~[org.eclipse.osgi-3.12.100.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:564) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176) ~[bundleFile:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192) ~[bundleFile:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:398) ~[?:?]
at jdk.nashorn.internal.runtime.Context.findClass(Context.java:1180) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.NativeJava.simpleType(NativeJava.java:546) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:326) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:318) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:314) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$41$16A$actions$cu1$restOf.L:3(file:/c:/openhab/conf/automation/lib/javascript/core/actions.js:23) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$39$actions.:program(file:/c:/openhab/conf/automation/lib/javascript/core/actions.js:3) ~[?:?]
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513) ~[jdk.scripting.nashorn:?]
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527) ~[jdk.scripting.nashorn:?]
... 73 more
19:16:24.465 [DEBUG] [re.automation.internal.RuleEngineImpl] - The rule '71a2abce18' is executed.
This is my developing Windows 10 computer but same happen on linux openhab server…
Im try sendNotification with official 3.0.0M2(Installed from UI) and 3.0.0.SNAPSHOT(Installed manualy) on linux server and on windows pc and it crash wirh ClassNotFoundException …
Im also myself modify and build openhabcloud addon from sources and make it simple for debuging only and make it by new RuleAction way like in Mail or other addons but still didn’t work…
NotificationAction.java:
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.io.openhabcloud;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.RuleAction;
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.io.openhabcloud.internal.CloudHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class provides static methods that can be used in automation rules
* for sending notifications to the native apps.
*
* @author Victor Belov - Initial contribution
* @author Kai Kreuzer - migrated code to ESH APIs
*
*/
@ThingActionsScope(name = "openhabcloud")
@NonNullByDefault
public class NotificationAction implements ThingActions {
private static final Logger logger = LoggerFactory.getLogger(NotificationAction.class);
private @Nullable CloudHandler handler;
@RuleAction(label = "send a push message", description = "Sends a push message.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendNotification(
@ActionInput(name = "userId") @Nullable String userId,
@ActionInput(name = "message") @Nullable String message) {
return sendNotification(userId, message, null, null);
}
@RuleAction(label = "send a push message", description = "Sends a push message.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendNotification(
@ActionInput(name = "userId") @Nullable String userId,
@ActionInput(name = "message") @Nullable String message, @ActionInput(name = "icon") @Nullable String icon,
@ActionInput(name = "severity") @Nullable String severity) {
if (userId == null) {
logger.warn("Cannot send push message as userId is missing.");
return false;
}
if (message == null) {
logger.warn("Cannot send push message as message is missing.");
return false;
}
try {
final CloudHandler handler = this.handler;
if (handler == null) {
logger.info("Handler is null, cannot send push message.");
return false;
} else {
logger.info("Push Message is send.");
return true; // handler.sendMail(builder.build());
}
} catch (Exception e) {
logger.warn("Could not send notification: {}", e.getMessage());
return false;
}
}
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof CloudHandler) {
this.handler = (CloudHandler) handler;
}
}
@Override
public @Nullable ThingHandler getThingHandler() {
return handler;
}
}
CloudHandler.java
package org.openhab.io.openhabcloud.internal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@NonNullByDefault
public class CloudHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(CloudHandler.class);
public CloudHandler(Thing thing) {
super(thing);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
}
@Override
public void initialize() {
updateStatus(ThingStatus.ONLINE);
}
}