Gert,

That worked! Thanks so very much.

Doug

-----Original Message-----
From: Gert Vanthienen [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 15, 2008 4:17 PM
To: [email protected]
Subject: Re: Stream closed error

Doug,

StreamSource is used througout ServiceMix for performance reasons, but 
the default implementations have one big drawback.  The stream can only 
be read once, a second attempt will result in the IOException you 
mention.  Your inbound message is probable of a re-readable Source type 
(e.g. a DOMSource), which can explain why using 
out.setContent(in.getContent()) solves your problem.

Could you try using a StringSource or BytesSource instead of a 
StreamSource when setting the out content?  Both Source implementations 
extend StreamSource, but are built for ServiceMix to allow 
re-readability by recreating the InputStream again every time the 
getInputStream() method is called.

Does this solve your issue?

Gert


[EMAIL PROTECTED] wrote:
> In my SE, I build an XML to send back to the client. The last two
lines
> of my SE are:
>
> out.setContent(new StreamSource(new StringReader(new String(inData)));
> getChannel().send(exchange);
>
> Where inData is a byte[] containing the content of the incoming
> NormalizedMessage from the client. It displays OK.
>
> When I build the project (mvn clean install), the unit test
application,
> MySpringComponentTest, throws an IO Exception complaining that the
> "stream" is closed on this statement:
>
> System.err.println(new
> SourceTransformer().toString(me.getOutMessage().getContent()));
>
> If I just set the out content to the in content (i.e.
> out.setContent(in.getContent())), then it works. Seems to be a problem
> with trying to build an out NormalizedMessage.
>
> Any ideas?
>
> Doug
>
>
>   

Reply via email to