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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -