Warning: Element can not be null

Ive been getting this warning a while now, Everything seems to work fine but this is kinda clogging my logs. No line or name is given… Any idea what causes it? finding a nullpointer with no lines or real errors is tough xD

java.lang.NullPointerException: Element cannot be null

at java.base/java.util.Objects.requireNonNull(Unknown Source)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$ValueNode.(PropertyTree.java:1159)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:327)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:293)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$MapNode.lambda$createNodeMap$1(PropertyTree.java:673)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$MapNode.lambda$createNodeMap$4(PropertyTree.java:688)

at java.base/java.util.stream.Collectors.lambda$toMap$68(Unknown Source)

at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source)

at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)

at java.base/java.util.Iterator.forEachRemaining(Unknown Source)

at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)

at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)

at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$MapNode.createNodeMap(PropertyTree.java:684)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$MapNode.createNodeMap(PropertyTree.java:673)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$MapNode.(PropertyTree.java:662)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:321)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:293)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$ArrayNode.createNodeList(PropertyTree.java:851)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$ArrayNode.(PropertyTree.java:838)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:324)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.nodeFromJson(PropertyTree.java:293)

at com.inductiveautomation.perspective.gateway.property.PropertyTree$ArrayNode.write(PropertyTree.java:921)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.lambda$write$1(PropertyTree.java:421)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.writeImpl(PropertyTree.java:464)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.write(PropertyTree.java:421)

at com.inductiveautomation.perspective.gateway.property.PropertyTree.writeAll(PropertyTree.java:415)

at com.inductiveautomation.perspective.gateway.model.ComponentModel.onPropertySync(ComponentModel.java:485)

at com.inductiveautomation.perspective.gateway.model.ViewModel.lambda$onPropSync$5(ViewModel.java:324)

at com.inductiveautomation.perspective.gateway.model.ComponentModel.dispatch(ComponentModel.java:430)

at com.inductiveautomation.perspective.gateway.model.ComponentModel.dispatch(ComponentModel.java:436)

at com.inductiveautomation.perspective.gateway.model.ComponentModel.dispatch(ComponentModel.java:436)

at com.inductiveautomation.perspective.gateway.model.ComponentModel.dispatch(ComponentModel.java:436)

at com.inductiveautomation.perspective.gateway.model.ViewModel.onPropSync(ViewModel.java:321)

at com.inductiveautomation.perspective.gateway.model.PageModel$Handlers.lambda$onPropSync$19(PageModel.java:948)

at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.thenAccept(Unknown Source)

at com.inductiveautomation.perspective.gateway.model.PageModel$Handlers.lambda$onPropSync$21(PageModel.java:946)

at com.inductiveautomation.perspective.gateway.api.LoggingContext.lambda$mdcWrap$0(LoggingContext.java:41)

at com.inductiveautomation.ignition.common.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:210)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)


Are you passing anything you manually encoded (in our quality encoding format) from the frontend to the backend?

This is happening when the backend receives some JSON content and tries to ‘inflate’ it into a property tree structure with associated quality values.

I pass a bunch of stuff around. I dont think i changed anything for any special “quality encoding formats” though.

With front to back you mean react js to the java delegate right? Or is it the one with (tree.write)?
How would i have to format this?

Something like a tree.write from the frontend, yeah. That’s just what’s happening based on the stacktrace, I can’t really narrow it down further than that. The MDC keys of the logged message should theoretically provide more info that may help narrow things down?

Nope i checked the wrapper.log and it doesnt include anything more than what i posted here. But i got an idea which ones could be null…

The thing is some of the props i use can be null and have to be null (as its not the same as undefined). Could i ‘inflate’ these values to quality values myself? would thatstill work as a treewrite?

Passing null itself should be fine. You can try using a different PropertyTree method, I think there’s a writeEncoded or similar?

1 Like

I see a readEncoded, but no write in the js library.
The value is any tho so maybe i can send a qualified value through it directly.

since in the java there do seem to be two functions for it. So that should probably work

        abstract PropertyTree.Node write(QualifiedValue var1, Origin var2);

        abstract PropertyTree.Node write(JsonElement var1, Origin var2);

Hm seems just putting the array in a quality value isnt enough. Nor is putting every object and its values to a QV
Im guessing i couldnt wrap the delegate or gatewayhook or something in a trycatch and catch this warning?

i tried overwriting the ComponentModel.onPropertySync in de delegate but it said cant overwrite the supertype :confused:

Anyways it seems putting on a filter on the gateway log configs also prevents the logs from entering the wrapper.log file so i guess thats good enough :smiley: