I had this error because when you use the ResponseBuilder
, it returns an OutboundJaxrsResponse
message that can not be processed with readEntity()
.
I noticed that I had this error only when I was calling the Jax-RS component directly. For exemple, if I have DefaultController
annotated with @Path("/default")
and if I tried to directly call its method, I could not use readEntity()
and had the same error as you.
defaultController.get();
Now, when I was using the grizzly2 test provider and using a client to target the Rest Url (in the previous case, it is /default
), the message I received in response was a ScopedJaxrsResponse. And then I could use the readEntity()
method.
target("/default").request.get();
In your case, you mocked the simpleClient in order to reply with a response built with ResponseBuilder
that is not processed by jersey. It's comparable to calling directly my DefaultController
method.
Without mocking the readEntity()
method, I suggest you to find a way to get your response processed by Jersey and turned into a ScopedJaxrsResponse
.
Hope that helps.