# Warning: Element can not be null

**URL:** <https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [November 24, 2021, 7:41am UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417 "2021-11-24T07:41:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 24, 2021, 7:41am UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/1 "2021-11-24T07:41:51Z")

</div>

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

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 24, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/2 "2021-11-24T16:44:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 25, 2021, 7:47am UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/3 "2021-11-25T07:47:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 29, 2021, 3:15pm UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/4 "2021-11-29T15:15:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 29, 2021, 3:37pm UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/5 "2021-11-29T15:37:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 29, 2021, 3:44pm UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/6 "2021-11-29T15:44:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 30, 2021, 7:57am UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/7 "2021-11-30T07:57:53Z")

</div>

> [@paul-griffith](#):
>
> `writeEncoded`

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

```auto
        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 😕

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 30, 2021, 11:58am UTC](https://forum.inductiveautomation.com/t/warning-element-can-not-be-null/53417/8 "2021-11-30T11:58:23Z")

</div>

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 😃

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c638bbd82f88291374427c711f29e2aa8e8d8111.png)
