Skip to content

Spring boot native image is not able to convert 'SORT' to json, throws org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON #35692

Closed as not planned
@pulsar-gupta

Description

@pulsar-gupta

I am generating spring boot 3 native image using -Pnative switch.
The DAO class fetches the data from DB with SORT object passed to DAO (below is sample)

Sort sort = sortType.equalsIgnoreCase(Sort.Direction.ASC.name()) ? Sort.by(sortField).ascending()
					: Sort.by(sortField).descending();
			Pageable pageWithElements = PageRequest.of(pageNum, projectsCount,sort);
			Page<ProjectDetailsListDto> result= projectDetailsDao.getProjectList(pageWithElements);

However, the call is failed when the call is returned from controller and the exception is

"org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.logException(207) : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Couldn't serialize object"

I have tried to provide hints to serialize the SORT object but this is also not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions