After update jackson kotlin module from 2.17 to 2.18 I have strange errors.
DTO is
data class StopWordModifyRequest(
@field:NotEmpty
@field:Size(min = 2, max = 255)
val word: String,
) : Serializable
test
mvc
.post(API_ROUTE) {
addCommonHeaders(KNOWN_USER_ID, ADMIN_ROLE)
content = """
{
"word": "childTest"
}
"""
}.andExpect { status { isCreated() } }
it works in 2.17, but error in 2.18:
Body = {"message":"Request body is invalid","details":[{"name":null,"description":"Cannot construct instance of `x.y.z.StopWordModifyRequest` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 25]"}]}
I can't google it quickly
Rather a little late but I encountered the exact same behavior today (migrating from Jackson 2.17 to 2.18).
Was able, with some effort, to figure out the issue and a clean solution.
Jackson, not being able to find the constructor, is very clearly the root cause. And I'm inclined to believe the problem occurs in the specific scenario of multiple existing constructors.
The clean and very straightforward solution is to add the @JsonCreator
annotation for each constructor Jackson will be using. Somehow it was decided this annotation is required as of 2.18 while it was not required before.