October 23, 2024
Chicago 12, Melborne City, USA
java

JaxRS: Generating incomplete JSON, Unable to serialize property 'finalScores' from FinalScoreResponse


I have an endpoint that when called gives this error:

2024-10-23 12:21:14,135 SEVERE [org.ecl.yas.int.SerializationContextImpl] (executor-thread-3) Generating incomplete JSON
2024-10-23 12:21:14,136 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-3) HTTP Request to /api/contacts/scores/compound/gambit-digital.com failed, error id: 971b0a13-4991-45ff-b720-dfb50644855f-20: jakarta.json.bind.JsonbException: Unable to serialize property 'finalScores' from at.hksolutions.gambit.boundary.jaxrs.FinalScoreResponse

The endpoint looks like this:

@GET
@Path("mypath")
@Produces(MediaType.APPLICATION_JSON)
public FinalScoreResponse getFinalScores() {
    .....
    // Some logic
    // Serialization fails:
    return new FinalScoreResponse(finalScores,  cache.lastUpdated);
}

A FinalScoreResponse looks like this:

public record FinalScoreResponse(
        List<FinalScore> finalScores,
        Date lastUpdated
) {
}

What I have tried:

  • Having FinalScoreResponse just contain lastUpdated – WORKS
  • Having the endpoint return List<FinalScore>directly – WORKS

So the issue is clearly related to List<FinalScore> not being able to be serialized within the FinalScoreResponse. It is weird though, because on its own, it can be serialized.

A FinalScore looks like this:

public record FinalScore(
        String id,
        String name,
        double score,
        int normalizedScore,
        String lifecycleStage
) {
}

Any solutions to having it serialized within the FinalScoreResponse?

Note: I can confirm the logic and endpoint gets called properly, it’s solely are serialization issue.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video