users@jersey.java.net

Re: [Jersey] entities encoding issues in the response

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 16 May 2008 11:48:29 +0200

Hi Arul,

That error appears independent of the RESTful service, is that the case?
i.e. this error would be reproducible if you wrote some stand alone Java
code to invoke a CXF JAX-WS Service ?

More specifically the problem appears to be with the XML document
returned from the CXF JAX-WS Service. The client is having trouble
parsing it, most likely for the reason that Tatu gives.

Paul.

Arul Dhesiaseelan wrote:
> Paul,
>
> I see these 2 errors when I started the REST service. My REST service
> invokes a CXF JAX-WS Service.
>
> org.apache.cxf.interceptor.Fault: Could not create XMLStreamReader
> (input was of
> encoding UTF-8).
> at
> org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInte
> rceptor.java:83)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> orChain.java:221)
> at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleR
> esponse(HTTPConduit.java:1988)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(H
> TTPConduit.java:1824)
> at
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:6
> 6)
> at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:583)
>
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndi
> ngInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
> orChain.java:221)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222)
> at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
> at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:17
> 7)
>
> .................
>
> Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte
> 0xfc (at c
> har #4, byte #-1)
> at
> com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:5
> 48)
> at
> com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:604
> )
> at
> com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:629
> )
> at
> com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFac
> tory.java:324)
> at
> org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInte
> rceptor.java:81)
> ... 75 more
> Caused by: java.io.CharConversionException: Invalid UTF-8 start byte
> 0xfc (at ch
> ar #4, byte #-1)
> at
> com.ctc.wstx.io.UTF8Reader.reportInvalidInitial(UTF8Reader.java:302)
> at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:188)
> at
> com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.jav
> a:245)
> at
> com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.
> java:132)
> at
> com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:5
> 43)
> ... 79 more
>
> Thanks!
> Arul
>
> Paul Sandoz wrote:
>> Arul Dhesiaseelan wrote:
>>> Hi Paul,
>>>
>>> Thanks for the help.
>>>
>>> Do you think if this would work?
>>
>> Only one way to really find out and that is to build and run it :-)
>>
>> You don't need to use a string writer, do this:
>>
>> public void writeTo(CellType cellType,
>> Class<?> type, Type genericType, Annotation annotations[],
>> MediaType mediaType, MultivaluedMap<String, Object> headers,
>> OutputStream out) throws IOException {
>> try {
>> JAXBContext jc = JAXBContext.newInstance(CellType.class);
>> Marshaller marshaller = jc.createMarshaller();
>> XMLStreamWriter swImpl =
>> XMLOutputFactory.newInstance().createXMLStreamWriter(out);
>> XMLStreamWriter sw = new MyStreamWriter(swImpl);
>> marshaller.marshal(cellType, sw);
>> } catch (XMLStreamException xse) {
>> System.out.println(xse.getMessage());
>> } catch (JAXBException je) {
>> System.out.println(je.getMessage());
>> }
>>
>> Plus you might consider moving the JAXBContext to the constructor and
>> use a field, as these things are expensive to create.
>>
>> Paul.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109