Issue
I have a nested resource like this:
@GetMapping("/tour-requests/{tourRequestId}/tour-request-messages")
@Secured({AuthoritiesConstants.ADMIN})
public ResponseEntity<List<TourRequestMessageDTO>> getTourRequestMessagesForTourRequest(
@PathVariable("tourRequestId") long tourRequestId,
TourRequestMessageCriteria criteria) {
...
}
When I call this resource, for example with GET api/tour-requests/1301/tour-request-messages
I get unexpected error:
{
"type": "https://zalando.github.io/problem/constraint-violation",
"title": "Constraint Violation",
"status": 400,
"path": "/api/tour-requests/1301/tour-request-messages",
"violations": [
{
"field": "tourRequestId",
"message": "Failed to convert property value of type 'java.lang.String' to required type 'io.github.jhipster.service.filter.LongFilter' for property 'tourRequestId'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'io.github.jhipster.service.filter.LongFilter' for property 'tourRequestId': no matching editors or conversion strategy found"
}
],
"message": "error.validation"
}
I tried to debug this, it seems that the exception is happening before the method is called-
Solution
The problem is that the search criteria has hijacked the path parameter tourRequestId
, as it happen to be also a possible search parameter of the generated QueryService.
That it is why it tried to convert the tourRequestId
parameter to LongFilter
.
Renaming the path variable to ìd` did also not helped, but after renaming it to something different, the problem disappeared.
Answered By - Meier