cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcos Díez Fernández <md...@tecsisa.com>
Subject RE: Extracting object from Response when ServerWebApplicationException occurs
Date Mon, 21 Mar 2011 18:05:52 GMT
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:sberyozkin@gmail.com] 
Enviado el: lunes, 21 de marzo de 2011 17:54
Para: users@cxf.apache.org
Asunto: Re: Extracting object from Response when ServerWebApplicationException occurs

Hi Marcos

2011/3/21 Marcos Díez Fernández <mdiez@tecsisa.com>

> 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


Mime
View raw message