Unable to serialize Pageable after library version updates

I updated my vaadin project from 24.5.7 with spring boot 3.2.12 to 24.6.0 with spring boot 3.4.1
spring-modulith.version from 1.2.4 to 1.3.0

after update, all the list screen endpoints are not able to be serialized. They are throwing error

com.vaadin.hilla.EndpointInvoker : Unable to deserialize an endpoint ‘UsersListController’ method ‘getListData’ parameter ‘pageable’ with type ‘org.springframework.data.domain.Pageable’

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.springframework.data.domain.Pageable (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: UNKNOWN; byte offset: #UNKNOWN]

Payload -

{
  "pageable": {
    "pageNumber": 0,
    "pageSize": 50,
    "sort": {
      "orders": [
        {
          "property": "fullName",
          "direction": "DESC",
          "ignoreCase": false,
          "nullHandling": "NATIVE"
        }
      ]
    }
  },
  "filter": {
    "@type": "and",
    "children": []
  },
  "andFilter": {
    "@type": "and",
    "children": []
  }
}
{
  "type": "com.vaadin.hilla.exception.EndpointValidationException",
  "message": "Validation error in endpoint 'UserListController' method 'getListData'",
  "validationErrorData": [
    {
      "parameterName": "pageable",
      "message": "Unable to deserialize an endpoint method parameter into type 'org.springframework.data.domain.Pageable'",
      "validatorMessage": null
    }
  ]
}

I tried to just update vaadin to 24.6.0 without any other update. Then also get same issue for pageable.

Do i have to write custom serializer and deserializer?

Are you using the default ObjectMapper or a custom one? The Hilla one has a mapper that replaces the Spring Pageable with a custom one that can be transferred.

I tried to upgrade a project locally and everything using a Pageable, like CRUD components for example, keeps working fine. I can see that generated code uses the custom Pageable.

There’s probably something custom in your project that skips the type mapping.

Can you share more details?

I tried to search for ObjectMapper in my repo, but there are no hits.

I have one JsonSerializer for one of the class with circular reference.

public class PersonSerializer extends JsonSerializer<SysPerson> {
    @Override
    public void serialize(Person value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value == null) {
            gen.writeNull();
        } else {
            gen.writeStartObject();
            gen.writeNumberField("id", value.getId());
            gen.writeStringField("name", value.getName());
            gen.writeEndObject();
        }
    }
}

Other than that in my application.yml i have these settings

  jackson:
    serialization:
      write-null-map-values: true
      fail-on-empty-beans: false
      write-dates-as-timestamps: false

What throws me off is, its working 24.5.7 but not on 24.6.0 ? Is there anything I should check?

In 24.5.7, request are getting hit to my endpoint, but in 24.6.0 it breaks even before hitting the endpoint. Its hard to debug that.

As I cannot reproduce, I’d ask you if you can debug the creation of the ObjectMapper in Hilla. There are changes in fix: add support for java8 date time in signals by taefi · Pull Request #2899 · vaadin/hilla · GitHub, look at EndpointControllerConfiguration and EndpointInvoker as their initialization has changed between 24.5 and 24.6.

1 Like

Could be related to Spring ai module affect bean creation order of `hillaEndpointObjectMapper` and `endpointInvoker` · Issue #3092 · vaadin/hilla · GitHub.

1 Like

I have not got chance to debug this issue yet.
I would like to add that, I am not using spring-ai, unless its getting included for copilot automatically.

Also I am using vaadin-core.

I’ve created fix: use `dependsOn` to force bean dependency by cromoteca · Pull Request #3098 · vaadin/hilla · GitHub that should fix it.

I tried again with new version, 24.6.2

Its creating bean hillaEndpointObjectMapper from createDefaultEndpoint since endPointMapperFactory is null

I see its breaking in EndpointInvoker.getVaadinEndpointParameters

Looks like another qualifier is missing. Sorry for that.