PK string returns in Spring response

Viewed 204

I am trying to return custom error message by using @ExceptionHandler but I receive extra junk value of PK in the response. I have attached the screen shot as well as code here in for any suggestion.

Anyone can suggest here?

Java Code:

@ExceptionHandler(value = InvalidMediaPKException.class)
public ResponseEntity<MediaErrorWsDTO> handleInvalidMediaPKException(final InvalidMediaPKException exception)
{
    final MediaErrorWsDTO errors = new MediaErrorWsDTO();
    errors.setCode(HttpStatus.NOT_FOUND.toString());
    errors.setMessage(String.format(INVALID_MEDIA_ERROR_MSG));
    return new ResponseEntity<MediaErrorWsDTO>(errors, HttpStatus.NOT_FOUND);
}

enter image description here

1 Answers
@XmlRootElement
public class MediaErrorWsDTO implements Serializable
{
// some code
}

I got issue resolved after adding @XmlRootElement on MediaErrorWsDTO class.

Related