Hi Sergey, I don't use ServerWebApplicationException.getMessage() and still get that exception.
Don't know what else I could try, so I think I'll go with the errorMessage unmarshalling, although it may not be the most 'proper/correct' way... Thanks a lot for your help BR, Marcos. -----Mensaje original----- De: Sergey Beryozkin [mailto:[email protected]] Enviado el: lunes, 21 de marzo de 2011 17:54 Para: [email protected] Asunto: Re: Extracting object from Response when ServerWebApplicationException occurs Hi Marcos 2011/3/21 Marcos Díez Fernández <[email protected]> > Hi Sergey, thanks for replying > > I'm trying the second approach you suggest: > > ErrorDetail errorDetail = (ErrorDetail) jsonProvider.readFrom( > (Class)ErrorDetail.class, > (Class)ErrorDetail.class, > new Annotation[]{}, > > MediaType.APPLICATION_JSON_TYPE, > response.getMetadata(), > > (InputStream)response.getEntity()); > > > But I get this compilation error: > > The method > readFrom(Class<Object>, Type, Annotation[], MediaType, > MultivaluedMap<String,String>, InputStream) > in the type JSONProvider is not applicable for the arguments > (Class, Class, Annotation[], MediaType, > MultivaluedMap<String,Object>, InputStream) > > > To make it compile, I've extracted the metadata values manually and > inserted them into a MetadataMap<String,String>: > > > The conversion is awkward, I know, so I just casted Map<String, Object> to plain Map and then to Map<String, String> - this is hidden inside ResponseReader... > Unfortunately, this produces an exception inside the JSONProvider: > > javax.xml.stream.XMLStreamException: > org.codehaus.jettison.json.JSONException: A JSONObject text must begin with > '{' at character 0 of > > So it looks like the received entity is not well understood or something > (?). > > Make sure you don't use ServerWebApplicationException.getMessage() which will consume the input stream. Cheers, Sergey
