camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanq <jqu...@abebooks.com>
Subject XStream and forcing ISO-8859-1 Encoding
Date Tue, 26 Jan 2010 19:29:49 GMT

I am trying to unmarshal an xml message from JMS that was originally
marshaled using Xstream.

When I create the message I am doing this:

XStream xstream = new XStream(new DomDriver("ISO-8859-1"));
template.sendBody(xstream.toXml(myObject));


On the consuming process I have this in my route:

from(endpoint).unmarshal().xstream().process(myProcessor);

The XStream unmarshal always fails due to non-UTF-8 characters.  And the
stacktrace shows that it was a UTF8 reader that failed.

So my question is - is there a way to initialize XStream to use a specific
DomDriver (with an encoding).  Or any way to specify the encoding to use by
default?

I tried adding this to the route (right after the from, and before the
unmarshal):
.setProperty(Exchange.CONTENT_ENCODING, constant("iso-8859-1"))

Didn't make a difference.


Here is the stack trace:

Caused by: com.thoughtworks.xstream.io.StreamException:  : Invalid UTF-8
start byte 0xa0 (at char #638, byte #-1)
	at
com.thoughtworks.xstream.io.xml.StaxReader.pullNextEvent(StaxReader.java:64)
	at
com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:137)
	at
com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:130)
	at
com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:109)
	at
com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:94)
	at com.thoughtworks.xstream.io.xml.StaxReader.<init>(StaxReader.java:44)
	at com.thoughtworks.xstream.io.xml.StaxReader.<init>(StaxReader.java:34)
	at
org.apache.camel.dataformat.xstream.XStreamDataFormat.createHierarchicalStreamReader(XStreamDataFormat.java:83)
	at
org.apache.camel.dataformat.xstream.AbstractXStreamWrapper.unmarshal(AbstractXStreamWrapper.java:88)
	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:51)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:186)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:155)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)
	at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
	at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:148)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
	at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
	at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
	at
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:170)
	at
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:156)
	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:141)
	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:155)
	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:93)
	at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
	at
org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:136)
	... 29 more
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0xa0
(at char #638, byte #-1)
	at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:708)
	at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
	at
com.thoughtworks.xstream.io.xml.StaxReader.pullNextEvent(StaxReader.java:49)
	... 55 more
Caused by: java.io.CharConversionException: Invalid UTF-8 start byte 0xa0
(at char #638, 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.ReaderSource.readInto(ReaderSource.java:84)
	at
com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57)
	at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:992)
	at com.ctc.wstx.sr.StreamScanner.getNext(StreamScanner.java:763)
	at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:1995)
	at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
-- 
View this message in context: http://old.nabble.com/XStream-and-forcing-ISO-8859-1-Encoding-tp27328336p27328336.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message