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.

Kotlin data class not work without annotation

See original GitHub issue

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>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
geoandcommented, Mar 15, 2020

So the reason why you aren’t seeing your ObjectMapperCustomizer run is because Quarkus believes that ObjectMapper bean 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 the quarkus-resteasy-jackson already 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 inject ObjectMapper into one of your CDI beans (you don’t need to use it, just inject it via field or constructor injection).

Thanks for reporting @miron4dev

2reactions
loicmathieucommented, Dec 9, 2019

Can you try with quarkus-resteasy-jackson and the Jackson kotlin module ?

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-module-kotlin</artifactId>
</dependency>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Data classes | Kotlin
Data classes cannot be abstract, open, sealed, or inner. Additionally, the generation of data class members follows these rules with regard to ...
Read more >
kotlin data class with annotations, why @DateTimeFormat ...
you registered kotlin module, it allows you to apply jackson annotations to constructor params without targeting but it doesn't work for ...
Read more >
Kotlin : Data Classes - Medium
The answer is yes, to make our work more easier Kotlin provides us the Data classes. These classes have all the functionalities of...
Read more >
Data Classes in Kotlin - Baeldung
The Kotlin language has introduced the concept of Data Classes, whose main purpose is to simply hold data without the boilerplate code ...
Read more >
kotlin data class with annotations, why @DateTimeFormat ...
you registered kotlin module, it allows you to apply jackson annotations to constructor params without targeting but it doesn't work for java validation ......
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