According to this code, it looks like the XML content-type is being hardcoded in the construction of the exception. To me, you have two options in this case
- Create your own exception for this same purpose (most elegant, but possibly overkill)
Do the following (a lot less elegant, but easy):
def exception = new DomainObjectNotFoundException(User.class, dto.id) def response = Response.fromResponse(exception.response).type(MediaType.APPLICATION_JSON) throw new WebApplicationException (newResponse)
Note that you will no longer be throwing a specific DomainObjectNotFoundException, so this may not be the best option for you. After writing that out, I would honestly just go with option 1.