question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MismatchedInputException: Cannot deserialize instance of `com.fasterxml.jackson.databind.node.ObjectNode` out of VALUE_NULL token

See original GitHub issue

When using readerForUpdating and updating an existing objectNode to a null Node this exception is triggered

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.fasterxml.jackson.databind.node.ObjectNode` out of VALUE_NULL token
 at [Source: UNKNOWN; line: -1, column: -1]

	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1468)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1242)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1148)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:107)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:82)
	at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.updateObject(JsonNodeDeserializer.java:361)
	at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.updateObject(JsonNodeDeserializer.java:373)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:120)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:82)
	at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2081)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1696)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1711)

Version information Jackson : 2.11.4 Java : openjdk-15.0.2

To Reproduce

  @Test
  void test() throws IOException {

    ObjectMapper objectMapper = new ObjectMapper();

    ObjectNode node = objectMapper.createObjectNode();
    node.set("test", objectMapper.createObjectNode());

    ObjectNode update = objectMapper.createObjectNode();
    update.set("test", NullNode.getInstance());

    ObjectReader objectReader = objectMapper.readerForUpdating(node);
    ObjectNode afterUpdateNode = objectReader.readValue(update, ObjectNode.class);

  }

Expected behavior In the code above node starts as

{
  "test": {}
}

and updated with the object update containing

{
  "test": null
}

after the update is applied afterUpdateNode should contain the following

{
  "test": null
}

But instead the above exception is raised. This looks to be same as #2325 but that was closed by the originator

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Stexxencommented, Feb 18, 2021

Sorry please ignore that I’ve just seen the comments in the file I added.

/**
 * Automatically generated from PackageVersion.java.in during
 * packageVersion-generate execution of maven-replacer-plugin in
 * pom.xml.
 */

Doh!.

0reactions
cowtowncodercommented, Feb 18, 2021

Unfortunately I have been unable to make it so that IDE auto-import would auto-generate that file: running mvn compile will create it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot deserialize instance of `java.util.ArrayList` out of ...
I have developed code but getting below error. com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java ...
Read more >
Cannot deserialize value of type java.util.ArrayList<com ...
Hi Guys, I am POSTing to https://api.infusionsoft.com/crm/rest/v2/contacts Example: { "email_addresses": { "0": { "email": "email@gmail.com" ...
Read more >
cannot deserialize instance out of start_array token - You.com
Im trying to deserialize a JSON list into a custom class with a list-typed parameter. However, this fails with com.fasterxml.jackson.databind.exc.
Read more >
Jackson Exceptions - Problems and Solutions - Baeldung
This exception is thrown if Jackson can't create an instance of the class, which happens if the class is abstract or it is...
Read more >
[Solved] com.fasterxml.jackson.databind.exc ...
[Solved] com.fasterxml.jackson.databind.exc. MismatchedInputException: Cannot deserialize instance of `XYZ` out of START_ARRAY token · Example of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found