Closed shutterfreak closed 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.
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
What does the whole network tab show when „MainUI crashes“?
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):
With broken script in place (MainUI crashes / hangs forever):
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.
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.
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.
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:
displayState
from a SCRIPT transform causing errors.@J-N-K Can you probably have a look at the REST API issue described here?
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.
Great, thanks. Let’s close this then.
Can you please reopen? I just checked that it still exists with Nashorn JS.
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:
$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.:Logging (
openhab.log
will show:Your environment
Browser console
Browser network traffic
Additional information
openHAB version 3.4.3 running on openHABian (Raspberry Pi 3B+).