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.

MissingKotlinParameterException: due to missing (therefore NULL) value for creator parameter … which is a non-nullable type

See original GitHub issue

We ran into the following issue when we tried to deserialize a JSON string coming from our Spring rest controller.

 FATAL EXCEPTION: main
    Process: com.example.driver, PID: 28305
    java.lang.IllegalStateException: Failed to load DataModel: com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class com.example.model.StorageDevice] value failed for JSON property storageDeviceId due to missing (therefore NULL) value for creator parameter storageDeviceId which is a non-nullable type
        at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 1764] (through reference chain: com.example.model.DataModel["storageDevices"]->java.util.ArrayList[0]->com.example.model.cargospace.StorageDevice["storageDeviceId"])
        at com.example.model.RestTourRepository$updateDataModel$1.onFailure(RestTourRepository.kt:38)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$2.run(ExecutorCallAdapterFactory.java:79)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6121)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

The object we try to construct looks like this:

@JsonIdentityInfo(
        generator = ObjectIdGenerators.PropertyGenerator::class,
        property = "storageDeviceId"
)
data class StorageDevice (
    val storageDeviceId: String,
    val configuration: AbstractStorageDeviceConfiguration,
    val storageDeviceLocation: StorageDeviceLocation
)

And the JSON string we receive is the following:

{
    "storageDeviceId": "71ba49f3-d8c8-425f-b7e4-29b8c49f417d",
    "id": 166,
    "configuration": {
        "storageDeviceConfigurationId": "c2c926b3-de70-491a-9f8d-514830d56a4b",
         …
    },
    "storageDeviceLocation": "1f64613b-6e96-4825-a489-faa00608516e",
    "new": false
}, …

We solved the issue by changing the val storageDeviceId: String to val storageDeviceId: String?. The value was then properly set after deserialization.

The question arises why we had to set it to nullable in the first place?

Versions: jackson-module-kotlin:2.9.0 jackson-annotations:2.9.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:27 (8 by maintainers)

github_iconTop GitHub Comments

25reactions
cowtowncodercommented, Apr 6, 2018

@asarkar Please do note that this is a fully volunteer-based open source project. We all have our lives, and participation here has to compete with many other things which generally are more important (family for example). So although I trust you did not mean your comment to sound like it, it came across bit strong as if there was some entitlement to quick service, solely based on the fact that you would like to see it fixed. There is no service expectation, and asking for status updates is typically not very helpful in getting things to move.

21reactions
asarkarcommented, Apr 6, 2018

Of course there are no service guarantees, let alone entitlements. However, what is lacking here is the acknowledgement that the reported issue is a bug, and will be addressed in a future release. “this is open source” argument is too much of a cliche, isn’t it? I work with and contribute to open sources myself, and one thing I often see is a strong resistance and/or obliviousness to problem reports, and putting the onus squarely on the reporter as if it’s their fault having found an issue with the code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson fails to deserialize Kotlin class - Stack Overflow
Room] value failed for JSON property arg0 due to missing (therefore NULL) value for creator parameter arg0 which is a non-nullable type at ......
Read more >
FasterXML/jackson-databind - Gitter
value failed for JSON property user_info due to missing (therefore NULL) value for creator parameter userInfo which is a non-nullable type at [Source: ......
Read more >
A brand new website interface for an even better experience!
MissingKotlinParameterException : due to missing (therefore NULL) value for creator parameter … which is a non-nullable type.
Read more >
在Spring Boot 中处理MissingKotlinParameterException · HonKit
众所周知kotlin 有空安全功能, 不能将一个非空类型变量赋值为null. ... failed for JSON property xxx due to missing (therefore NULL) value for creator parameter ...
Read more >
com.fasterxml.jackson.module.kotlin.KotlinValueInstantiator.kt ...
NullsAsEmptyProvider import com.fasterxml.jackson.databind.deser.impl. ... ${jsonProp.name} due to missing (therefore NULL) value for creator parameter ...
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