quarkus: Kotlin data class not work without annotation
I try https://quarkus.io/guides/rest-json on kotlin. I want to use simple data class, without any annotation.
data class Fruit(
val name : String,
val description : String)
if I use quarkus-resteasy-jackson
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
If I use quarkus-resteasy-jsonb
I get No default constructor found.
This is bad practice to use default constructor in this case.
related topic
<quarkus.platform.version>1.0.1.Final</quarkus.platform.version>
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (13 by maintainers)
Commits related to this issue
- Ensure that the Kotlin compiler adds method param names to bytecode We already do this for Java, so let's make it consistent for Kotlin too Fixes: #6041 — committed to geoand/quarkus by geoand 5 years ago
- Merge pull request #6310 from geoand/#6041 Ensure that the Kotlin compiler adds method param names to bytecode — committed to quarkusio/quarkus by geoand 5 years ago
- Ensure that the Kotlin compiler adds method param names to bytecode We already do this for Java, so let's make it consistent for Kotlin too Fixes: #6041 — committed to gsmet/quarkus by geoand 5 years ago
So the reason why you aren’t seeing your
ObjectMapperCustomizerrun is because Quarkus believes thatObjectMapperbean is not being used at all (see this for more details). This is a bug with Amazon Lamdba + Jackson integration which can be fixed very easily on our side (by making the bean unremovable like thequarkus-resteasy-jacksonalready does), but I know that @patriot1burke is working on a lot of improvements that include this one as well.For now the workaround is to include
quarkus-resteasy-jackson, but that won’t be needed once we fix the bug. Another potential workaround would be for you to injectObjectMapperinto one of your CDI beans (you don’t need to use it, just inject it via field or constructor injection).Thanks for reporting @miron4dev
Can you try with
quarkus-resteasy-jacksonand the Jackson kotlin module ?