What are you asking for, I replaced it
response.getEntity(String.class);
by this
response.getEntityStream().toString();
But there may be other problems associated with Jersey 2, I could get it to work by replacing these imports
import jersey.spi.container.servlet.ServletContainer; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource;
By these
import org.glassfish.jersey.servlet.ServletContainer; import org.glassfish.jersey.client.ClientResponse; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder;
and in the code (since I used Jetty) I had to replace this
servletHolder.setInitParameter("com.sun.jersey.config.property.packages", "resources");
by this
servletHolder.setInitParameter("jersey.config.server.provider.packages", "resources");
and this one
WebResource webResource = client.resource("http://url_u_want_to_connect"); ClientResponse response = webResource.accept("application/json")
by this
WebTarget webTarget = client.target("http://url_u_want_to_connect"); ClientResponse response = webTarget.request("application/json")
Finally, here is a link to the “latest” docs (about Jersey 2.x, in 2013)
https://jersey.java.net/documentation/latest/user-guide.html
source share