I am trying to create a response with responsebuilder. When I pass string in entity it works fine but when I pass some error class it doesnot works.
Here is code
1) Working fine
Response.status(400).entity("test").build();
2) Not working
Response.status(400).entity(new MyCustomExceptions(400,"My bad request")).build();
With above code I am getting error
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=text/plain
when I call this service with above code I am getting 500 error instead of 400.But in 1st case I am getting proper 400 error.
- Just wanted to understand if I pass object to entity then do I need to override some methods in class MyCustomExceptions?
- How response is created from MyCustomExceptions object?
- If I pass string to entity it works fine.Why?