openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
214 stars 235 forks source link

[MainUI] Items overview page does not load when script transformation throws error #1867

Closed shutterfreak closed 1 year ago

shutterfreak commented 1 year ago

The problem

Using a JS transform script which throws e ClassNotFoundException completely breaks mainUI.

To fix this problem once it occurs, there are 2 options requiring access to the file system:

  1. delete the offending JS transform (foo.js)
  2. remove the offending JS transform pattern in the JSON database: stop openHAB service, edit $OPENHAB_USERDATA/jsondb/org.openhab.core.items.Metadata.json to remove the offending metadata by hand, then start the openHAB service.

Expected behavior

MainUI should not crash when this type of errors occurs.

Steps to reproduce

Create a JS transform 'foo.js' as a file under $OPENHAB_CONF/transform/foo.js that will fail, e.g.:

(function(data) {
    var QuantityType = Java.type('org.openhab.core.library.types.QuantityType');

    return 'test';
})(input)

Logging (openhab.log will show:

==> /var/log/openhab/openhab.log <==
2023-04-30 10:56:33.255 [ERROR] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - Problem with writing the data, class org.openhab.core.io.rest.Stream2JSONInputStream, ContentType: application/json
2023-04-30 10:56:33.257 [ERROR] [internal.JSONResponseExceptionMapper] - Unexpected exception occurred while processing REST request.
java.lang.RuntimeException: java.lang.ClassNotFoundException: org.openhab.core.library.types.QuantityType cannot be found by org.apache.aries.jax.rs.whiteboard_2.0.0
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:531) ~[jdk.scripting.nashorn:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:428) ~[jdk.scripting.nashorn:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:521) ~[jdk.scripting.nashorn:?]
    at javax.script.CompiledScript.eval(CompiledScript.java:89) ~[java.scripting:?]
    at org.openhab.transform.javascript.internal.JavaScriptTransformationService.transform(JavaScriptTransformationService.java:126) ~[?:?]
    at org.openhab.core.transform.TransformationHelper.transform(TransformationHelper.java:125) ~[?:?]
    at org.openhab.core.transform.TransformationHelper.transform(TransformationHelper.java:100) ~[?:?]
    at org.openhab.core.io.rest.core.item.EnrichedItemDTOMapper.considerTransformation(EnrichedItemDTOMapper.java:148) ~[?:?]
    at org.openhab.core.io.rest.core.item.EnrichedItemDTOMapper.map(EnrichedItemDTOMapper.java:81) ~[?:?]
    at org.openhab.core.io.rest.core.item.EnrichedItemDTOMapper.map(EnrichedItemDTOMapper.java:64) ~[?:?]
    at org.openhab.core.io.rest.core.internal.item.ItemResource.lambda$2(ItemResource.java:222) ~[?:?]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
    at java.util.HashMap$KeySpliterator.tryAdvance(HashMap.java:1642) ~[?:?]
    at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:294) ~[?:?]
    at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206) ~[?:?]
    at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:169) ~[?:?]
    at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300) ~[?:?]
    at java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681) ~[?:?]
    at org.openhab.core.io.rest.Stream2JSONInputStream.fillBuffer(Stream2JSONInputStream.java:91) ~[?:?]
    at org.openhab.core.io.rest.Stream2JSONInputStream.read(Stream2JSONInputStream.java:67) ~[?:?]
    at java.io.InputStream.read(InputStream.java:280) ~[?:?]
    at java.io.InputStream.transferTo(InputStream.java:704) ~[?:?]
    at org.openhab.core.io.rest.core.internal.GsonMessageBodyWriter.writeTo(GsonMessageBodyWriter.java:83) ~[?:?]
    at org.openhab.core.io.rest.core.internal.MediaTypeExtension.writeTo(MediaTypeExtension.java:84) ~[?:?]
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1543) ~[bundleFile:3.4.5]
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:249) ~[bundleFile:3.4.5]
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:122) ~[bundleFile:3.4.5]
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:84) ~[bundleFile:3.4.5]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[bundleFile:3.4.5]
    at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:90) ~[bundleFile:3.4.5]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298) ~[bundleFile:3.4.5]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:222) ~[bundleFile:3.4.5]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) ~[bundleFile:3.1.0]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:273) ~[bundleFile:3.4.5]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) ~[bundleFile:9.4.46.v20220331]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:74) ~[bundleFile:?]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) ~[bundleFile:9.4.46.v20220331]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294) ~[bundleFile:?]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[bundleFile:9.4.46.v20220331]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:90) ~[bundleFile:?]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) ~[bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [bundleFile:9.4.46.v20220331]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [bundleFile:9.4.46.v20220331]
    at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.ClassNotFoundException: org.openhab.core.library.types.QuantityType cannot be found by org.apache.aries.jax.rs.whiteboard_2.0.0
    at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:529) ~[org.eclipse.osgi-3.17.200.jar:?]
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:524) ~[org.eclipse.osgi-3.17.200.jar:?]
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) ~[org.eclipse.osgi-3.17.200.jar:?]
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) ~[org.eclipse.osgi-3.17.200.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:622) ~[org.eclipse.osgi-3.17.200.jar:?]
    at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176) ~[bundleFile:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]
    at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192) ~[bundleFile:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
    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$110$1A$\^eval\_/0x4e52a6c8.L:1(<eval>:2) ~[?:?]
    at jdk.nashorn.internal.scripts.Script$Recompilation$109$\^eval\_/0x550c94b0.:program(<eval>:1) ~[?:?]
    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:?]
    ... 75 more

Your environment

runtimeInfo:
  version: 3.4.3
  buildString: Release Build
locale: en-BE
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.18
  javaVendor: Raspbian
  osName: Linux
  osVersion: 6.1.21-v7+
  osArchitecture: arm
  availableProcessors: 4
  freeMemory: 6851840
  totalMemory: 324403200
  startLevel: 100
bindings:
  - buienradar
  - nikohomecontrol
  - openweathermap
  - sonos
  - systeminfo
  - telegram
  - tradfri
  - zwave
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 4
    language: en-GB
    languages:
      - en-GB
    onLine: true
    platform: MacIntel
  screen:
    width: 1680
    height: 1050
    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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15
    (KHTML, like Gecko) Version/16.4.1 Safari/605.1.15
timestamp: 2023-04-30T09:14:38.141Z

Browser console

[Error] Viewport argument key "minimal-ui" not recognized and ignored. (items, line 1)

[Debug] loading i18n messages from: ./bg.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ca.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./cs.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./da.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./de.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./el.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./en.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./es.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fa.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fi.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fr.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./he.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./hu.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./it.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./iw.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lb.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lt.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./nl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./no.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt-BR.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ru.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./tr.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./uk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./zh.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./bg.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ca.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./cs.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./da.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./de.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./el.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./en.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./es.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fa.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fi.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fr.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./he.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./hu.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./it.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./iw.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lb.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./nl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./no.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt-BR.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ru.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./uk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./zh.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./bg.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ca.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./cs.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./da.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./de.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./el.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./en.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./es.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fa.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fi.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./fr.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./he.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./hu.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./it.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./iw.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lb.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./lv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./nl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./no.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt-BR.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./pt.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./ru.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sl.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./sv.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./uk.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] loading i18n messages from: ./zh.json (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] Initializing state tracking store proxy (app.d702c20a4e09bf4012ea.js, line 7)

[Debug] sseConnected – false (app.d702c20a4e09bf4012ea.js, line 35)

[Error] Unhandled Promise Rejection: parseerror

Browser network traffic

Additional information

openHAB version 3.4.3 running on openHABian (Raspberry Pi 3B+).

florian-h05 commented 1 year ago

Can you please check what the GET /rest/ call returns when this happens? You can see that in the network tools of the browser‘s dev tools, just search for a request to /rest/ and tell me the response and the response code.

shutterfreak commented 1 year ago

Here's the JSON object returned:

{"version":"5","locale":"en_BE","measurementSystem":"SI","runtimeInfo":{"version":"3.4.3","buildString":"Release Build"},"links":[{"type":"audio","url":"http://homebrainz.local:8080/rest/audio"},{"type":"module-types","url":"http://homebrainz.local:8080/rest/module-types"},{"type":"templates","url":"http://homebrainz.local:8080/rest/templates"},{"type":"sitemaps","url":"http://homebrainz.local:8080/rest/sitemaps"},{"type":"logging","url":"http://homebrainz.local:8080/rest/logging"},{"type":"ui","url":"http://homebrainz.local:8080/rest/ui"},{"type":"systeminfo","url":"http://homebrainz.local:8080/rest/systeminfo"},{"type":"things","url":"http://homebrainz.local:8080/rest/things"},{"type":"profile-types","url":"http://homebrainz.local:8080/rest/profile-types"},{"type":"auth","url":"http://homebrainz.local:8080/rest/auth"},{"type":"transformations","url":"http://homebrainz.local:8080/rest/transformations"},{"type":"config-descriptions","url":"http://homebrainz.local:8080/rest/config-descriptions"},{"type":"links","url":"http://homebrainz.local:8080/rest/links"},{"type":"uuid","url":"http://homebrainz.local:8080/rest/uuid"},{"type":"spec","url":"http://homebrainz.local:8080/rest/spec"},{"type":"voice","url":"http://homebrainz.local:8080/rest/voice"},{"type":"persistence","url":"http://homebrainz.local:8080/rest/persistence"},{"type":"addons","url":"http://homebrainz.local:8080/rest/addons"},{"type":"channel-types","url":"http://homebrainz.local:8080/rest/channel-types"},{"type":"events","url":"http://homebrainz.local:8080/rest/events"},{"type":"thing-types","url":"http://homebrainz.local:8080/rest/thing-types"},{"type":"rules","url":"http://homebrainz.local:8080/rest/rules"},{"type":"services","url":"http://homebrainz.local:8080/rest/services"},{"type":"habpanel","url":"http://homebrainz.local:8080/rest/habpanel"},{"type":"discovery","url":"http://homebrainz.local:8080/rest/discovery"},{"type":"bindings","url":"http://homebrainz.local:8080/rest/bindings"},{"type":"inbox","url":"http://homebrainz.local:8080/rest/inbox"},{"type":"iconsets","url":"http://homebrainz.local:8080/rest/iconsets"},{"type":"items","url":"http://homebrainz.local:8080/rest/items"}]}

The HTTP response headers are:

HTTP/1.1 200 OK
Content-Type: application/json
Date: Sun, 30 Apr 2023 18:02:47 GMT
Server: Jetty(9.4.46.v20220331)
Transfer-Encoding: Identity
florian-h05 commented 1 year ago

What does the whole network tab show when „MainUI crashes“?

shutterfreak commented 1 year ago

I attached the entire network tab for a successful requestt of the items overview, and again with the broken script.

Without the broken script (loads OK):

Screenshot 2023-04-30 at 20 42 39

With broken script in place (MainUI crashes / hangs forever):

Screenshot 2023-04-30 at 20 43 12
florian-h05 commented 1 year ago

Your issue description is not as detailed as it should be, there is a reason why we have issue templated that ask for specific stuff: get the important information without having to ask for it. This saves everyone time. First of all, MainUI is not „crashing completely“, given your screenshots it seems that only the Items page is not loading. Second, the issue template asks for the network traffic from the browser‘s dev tools. Why didn‘t you follow the issue template?

Back to the issue: What does the /rest/items request return and what is the response code when the Items page does not load? Given your log output, it seems that openHAB Core is unable to build the response for the /rest/items endpoint, MainUI therefore does receive nothing and can only show nothing/forever loading.

shutterfreak commented 1 year ago

The problem was not limited to the items page. The entire MainUI was locked up (black screen, no text), no way to navigate anywhere. That’s also why I only provided screenshots and debug logs from that page.

So yes, it really looked like MainUI was completely gone, requiring one of the 2 file system edits I documented in the issue to bring MainUI back to life.

I now see that on the screenshots I provided part of the UI got rendered, which I repeat wasn’t the case in earlier attempts.

I’ll provide the requested information when I have ssh access to my Raspberry Pi.

florian-h05 commented 1 year ago

Okay, this seems like a core problem then.

MainUI won't show up when the GET /rest/ request fails, and the Items page won't load the Items when the GET /rest/items request fails. I see that you are on openHAB 3.4.3, I'll need to test on the latest 4.0 SNAPSHOTs if the problem persists and if yes, report that to the core maintainers.

shutterfreak commented 1 year ago

An error occurs in the returned JSON code with a GET /rest/items request.

I pasted the 2 last entries of that response below (separated with a new line for clarity):

{"members":[],"link":"http://homebrainz.local:8080/rest/items/gPersistRestoreOnStartup","state":"NULL","editable":true,"type":"Group","name":"gPersistRestoreOnStartup","label":"Persistence Strategy - restoreOnStartup","category":"settings","tags":[],"groupNames":["gPersistenceStrategies"]},
{"link":"http://homebrainz.local:80"{\"error\":{\"message\":\"java.lang.ClassNotFoundException: org.openhab.core.library.types.QuantityType cannot be found by org.apache.aries.jax.rs.whiteboard_2.0.0\",\"http-code\":500,\"exception\":{\"class\":\"java.lang.RuntimeException\",\"message\":\"java.lang.ClassNotFoundException: org.openhab.core.library.types.QuantityType cannot be found by org.apache.aries.jax.rs.whiteboard_2.0.0\",\"localized-message\":\"java.lang.ClassNotFoundException: org.openhab.core.library.types.QuantityType cannot be found by org.apache.aries.jax.rs.whiteboard_2.0.0\",\"cause\":\"java.lang.ClassNotFoundException\"}}}"

It is clear that the JSON body is invalid, which may explain the unresponsiveness of MainUI.

Most likely the exception was written to the JSON body (instead of writing to the relevant logger) while processing the items.

I suppose these are 2 issues:

  1. REST API hiccup when trying to produce displayState from a SCRIPT transform causing errors.
  2. MainUI hangs when receiving invalid / malformed response from REST API
florian-h05 commented 1 year ago

@J-N-K Can you probably have a look at the REST API issue described here?

J-N-K commented 1 year ago

On OH4 this seems to be fixed:

17:21:19.422 | ERROR | pool-4-thread-1      | b.automation.script.javascript.stack | 250 | Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: Access to host class org.openhab.core.library.types.QuantitType is not allowed or does not exist.
    at <js>.:anonymous(<eval>:2) ~[?:?]
    at <js>.:program(<eval>:1) ~[?:?]
    at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]
    at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]
    at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426) ~[?:?]
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262) ~[java.scripting:?]
    at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
    at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
    at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
    at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
    at org.openhab.core.automation.module.script.ScriptTransformationService.transform(ScriptTransformationService.java:215) ~[?:?]
    at org.openhab.core.transform.TransformationHelper.transform(TransformationHelper.java:125) ~[?:?]
    at org.openhab.core.transform.TransformationHelper.transform(TransformationHelper.java:100) ~[?:?]
    at org.openhab.core.io.rest.sse.internal.SseItemStatesEventBuilder.getDisplayState(SseItemStatesEventBuilder.java:120) ~[?:?]
    at org.openhab.core.io.rest.sse.internal.SseItemStatesEventBuilder.buildEvent(SseItemStatesEventBuilder.java:81) ~[?:?]
    at org.openhab.core.io.rest.sse.SseResource.handleEventBroadcastItemState(SseResource.java:263) ~[?:?]
    at org.openhab.core.io.rest.sse.SseResource.lambda$1(SseResource.java:154) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
17:21:19.425 | WARN  | pool-4-thread-1      | e.internal.SseItemStatesEventBuilder | 180 | Failed transforming the state '5464129536 B' on item 'Local_computer_Verfugbar' with pattern 'JS(broken.js):%s': Failed to execute script.
florian-h05 commented 1 year ago

Great, thanks. Let’s close this then.

J-N-K commented 1 year ago

Can you please reopen? I just checked that it still exists with Nashorn JS.