java - Class cast exception in jersey project? -
i have jersey rest project , 1 newbie question. server side:
throw new webapplicationexception(response.status(status.not_found) .entity("no access token found").build());
from client side
else if (status.fromstatuscode(response.getstatus()) == status.not_found || status.fromstatuscode(response.getstatus()) == status.gone) { final verifytokenresponse verifytokenresponse = new verifytokenresponse(); verifytokenresponse.seterror((string) response.getentity()); return verifytokenresponse; }
problem
java.lang.classcastexception: org.glassfish.jersey.client.httpurlconnector$1 cannot cast java.lang.string
why can't error string on client side ? correct (string) response.getentity() ?
you need use response.readentity(string.class)
instead of (string) response.getentity()
Comments
Post a Comment