Hi All,
I am trying the Gatekeeper Script and test example for a week but I am facing the below error, again by again.
my system configuration is this.
runtimeInfo:
version: 3.4.0.M6
buildString: Milestone Build
locale: tr-TR
systemInfo:
configFolder: /etc/openhab
userdataFolder: /var/lib/openhab
logFolder: /var/log/openhab
javaVersion: 11.0.17
javaVendor: Ubuntu
osName: Linux
osVersion: 5.15.80-sunxi
osArchitecture: arm
availableProcessors: 4
freeMemory: 113579352
totalMemory: 258334720
startLevel: 100
bindings:
- denonmarantz
- lirc
- serial
- telegram
clientInfo:
device:
ios: false
android: false
androidChrome: false
desktop: true
iphone: false
ipod: false
ipad: false
edge: false
ie: false
firefox: false
macos: false
windows: true
cordova: false
phonegap: false
electron: false
nwjs: false
webView: false
webview: false
standalone: false
os: windows
pixelRatio: 1
prefersColorScheme: light
isSecureContext: false
locationbarVisible: true
menubarVisible: true
navigator:
cookieEnabled: true
deviceMemory: N/A
hardwareConcurrency: 8
language: en-US
languages:
- en-US
- en
- tr
onLine: true
platform: Win32
screen:
width: 1920
height: 1080
colorDepth: 24
support:
touch: false
pointerEvents: true
observer: true
passiveListener: true
gestures: false
intersectionObserver: true
themeOptions:
dark: dark
filled: true
pageTransitionAnimation: default
bars: light
homeNavbar: default
homeBackground: default
expandableCardAnimation: default
userAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/108.0.0.0 Safari/537.36
timestamp: 2022-12-25T20:30:22.184
and the Gatekeeper test code is;
var { time } = require('openhab');
var { gatekeeper } = require('openhab_rules_tools');
var logger = log('rules_tools.Gatekeeper Tests');
var testFunGen = (test, num) => {
logger.debug('generating function for {} run{}', test, num);
return () => {
logger.debug('{}: Test {} ran', test, num);
cache.put(test + '_run' + num, time.toZDT());
};
}
logger.info('Starting Gatekeeper tests');
var reset = (test) => {
logger.debug('resetting {}');
cache.put(test, null);
logger.debug('resetting {}', test + '_start');
cache.put(test + '_start', null);
for (var i = 1; i <= 4; i++) {
logger.debug('resetting {}', test + '_run' + 1)
cache.put(test + '_run' + i, null);
}
}
// Test 1: Scheduling
var gk1 = new gatekeeper.Gatekeeper();
var TEST1 = ruleUID + '_test1';
reset(TEST1);
cache.put(TEST1 + '_start', time.ZonedDateTime.now());
gk1.addCommand('PT1s', testFunGen(TEST1, 1));
gk1.addCommand('PT2s', testFunGen(TEST1, 2));
gk1.addCommand('PT3s', testFunGen(TEST1, 3));
gk1.addCommand(500, testFunGen(TEST1, 4));
actions.ScriptExecution.createTimer(time.toZDT('PT6.51s'), () => {
var success = true;
const start = cache.get(TEST1 + '_start');
const run1 = cache.get(TEST1 + '_run1');
const run2 = cache.get(TEST1 + '_run2');
const run3 = cache.get(TEST1 + '_run3');
const run4 = cache.get(TEST1 + '_run4');
if (start === null) {
logger.error('{} Failed to get starting timestamp', TEST1);
success = false;
}
if (success && run1 === null) {
logger.error('{} run1 failed to run!', TEST1);
success = false;
}
if (success && run2 === null) {
logger.error('{} run2 failed to run!', TEST1);
success = false;
}
if (success && run3 === null) {
logger.error('{} run3 failed to run!', TEST1);
success = false;
}
if (success && run4 === null) {
logger.error('{} run4 failed to run!', TEST1);
success = false;
}
if (success) {
logger.info('\n{}\n{}\n{}\n{}\n{}', start.toString(), run1.toString(), run2.toString(), run3.toString(), run4.toString());
const dur1 = time.Duration.between(run1, run2).seconds();
const dur2 = time.Duration.between(run2, run3).seconds();
const dur3 = time.Duration.between(run3, run4).seconds();
if (start.isAfter(run1)) {
logger.error('{} failed, run1 ran before start!', TEST1);
success = false;
}
if (success && dur1 != 1) {
logger.error('{} failed, time between run1 and run2 is {} seconds.', dur1);
success = false;
}
if (success && dur2 != 2) {
logger.error('{} failed, time between run2 and run3 is {} seconds', dur2);
success = false;
}
if (success && dur3 != 3) {
logger.error('{} failed, time between run3 and run4 is {} seconds', dur3);
}
if (success) {
logger.info('Gatekeeper test 1 success!');
}
}
});
// Test 2: cancelAll
var gk2 = new gatekeeper.Gatekeeper();
var TEST2 = ruleUID + '_test2'
reset(TEST2);
gk2.addCommand('PT1.5s', testFunGen(TEST2, 1));
gk2.addCommand('PT2s', testFunGen(TEST2, 2));
gk2.addCommand('PT3s', testFunGen(TEST2, 3));
gk2.addCommand(500, testFunGen(TEST2, 4));
actions.ScriptExecution.createTimer(time.ZonedDateTime.now().plus(2750, time.ChronoUnit.MILLIS), () => {
var success = true;
const run1 = cache.get(TEST2 + '_run1');
const run2 = cache.get(TEST2 + '_run2');
const run3 = cache.get(TEST2 + '_run3');
const run4 = cache.get(TEST2 + '_run4');
if (!run1) {
logger.error('{} failed, run1 did not run', TEST2);
success = false;
}
if (success && !run2) {
logger.error('{} failed, run2 did not run', TEST2);
success = false;
}
if (success && run3) {
logger.error('{} failed, run3 ran too soon', TEST2);
success = false;
}
if (success && run4) {
logger.error('{} failed, run4 ran too soon', TEST2);
success = false;
}
if (success) {
gk2.cancelAll();
actions.ScriptExecution.createTimer(time.toZDT('PT4s'), () => {
var success = true;
const run3 = cache.get(TEST2 + '_run3');
const run4 = cache.get(TEST2 + '_run4');
if (run3) {
logger.error('{} failed, run3 ran after being cancelled');
success = false;
}
if (success && run4) {
logger.error('{} failed, run4 ran after being cancelled');
}
if (success) {
logger.info('Gatekeeper test 2 success!')
}
});
}
});
and the error is;
2022-12-21 00:26:03.560 [ERROR] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No message body reader has been found for class java.util.Map, ContentType: application/octet-stream
2022-12-21 00:26:03.617 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type
at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1473)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processRequestBodyParameter(JAXRSUtils.java:950)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:881)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:215)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:79)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:273)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:74)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:90)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.base/java.lang.Thread.run(Thread.java:829)
Do you have any suggestions or help?
Thank you…