On Thu, Aug 27, 2009 at 9:47 AM, Farhad Dehghani<[email protected]> wrote:
> Thanks Claus,
> I've actually tried that too. The result is the same !! Any other
> suggestions?
>

The body content is what Camel wants to store in the file. It can deal
with most common types such as String, Stream etc.
But you have an Object that is a java.util.List. So you need to
transform this to something that can be written to a file, such as a
String.

Caused by: org.apache.camel.NoTypeConversionAvailableException: No
type converter available to convert from type: java.util.ArrayList to
the required type: java.io.InputStream with value
[bean:trailerHandler]



> -Farhad
>
> Begin forwarded message:
>
>> Date: August 26, 2009 7:12:26 AM GMT+02:00
>> Subject: Re: renaming a file in a bean
>> Source: Nabble - Camel - Users
>> Author: Claus Ibsen-2
>>
>> Hi
>>
>> You want to replace the existing header so use IN
>>  exchange.getOut().setHeader(Exchange.FILE_NAME, rename(fileName));
>>
>> Should be:
>>  exchange.getIn().setHeader(Exchange.FILE_NAME, rename(fileName));
>>
>>
>> On Wed, Aug 26, 2009 at 2:02 PM, Farhad Dehghani<m...@...> wrote:
>>
>> > Hi,
>> > Please consider the route definition below:
>> > --------
>> > <camel:camelContext id="vod_workflow">
>> >        <camel:package>com.nordija.itv.vod.workflow</camel:package>
>> >  <camel:route>
>> >    <camel:from uri="file:///tmp/vodwof?recursive=true" />
>> >        <camel:to uri="file:///tmp/vodIncoming?tempPrefix=.inprogress_"
>> > />
>> >        <camel:to uri="bean:vodIncomingProcessor"/>
>> >        <camel:to uri="direct:route_1"/>
>> >  </camel:route>
>> >  <camel:route>
>> >        <camel:from uri="direct:route_1"/>
>> >        <camel:to uri="bean:trailerHandler"/>
>> >        <camel:to uri="file:///tmp/trailer?tempPrefix=.inprogress_"/>
>> >        <camel:to uri="direct:end"/>
>> >  </camel:route>
>> >  ....
>> > </camel:camelContext>
>> > <bean name="trailerHandler"
>> > class="com.nordija.itv.vod.workflow.TarilerHandlerImpl" />
>> > ---------
>> > The vodIncomingProcessor is a @RecipientList annotated bean that decides
>> > if
>> > the file in question should be handled by the "trailerHandler" or
>> > something
>> > else.
>> > The trailerHandler needs among other things to rename the resulting
>> > file.
>> > The following code is a very simplified version of the bean:
>> >
>> > @Service(value="trailerHandler")
>> > public class TarilerHandlerImpl implements TrailerHandler {
>> >        public void handleTrailer(Exchange exchange) {
>> >                if(exchange != null){
>> >                        String fileName =
>> > (String)exchange.getIn().getHeader(Exchange.FILE_NAME);
>> >                        if(fileName != null){
>> >
>> >  exchange.getOut().setHeader(Exchange.FILE_NAME, rename(fileName));
>> >                        }
>> >                }
>> >        }
>> > }
>> >
>> > The "rename(String filename)" method renames the file and it's
>> > implementation is not relevant here. For test, it just prefix the
>> > filename
>> > with "trailer_".
>> > When I run the application, the following exception is thrown, and the
>> > trailerHandler gets called again and again.
>> >
>> > I appreciate any help,
>> > -Farhad Dehghani
>> >
>> > 13:02:20,913 INFO  [STDOUT] 13:02:20,911 ERROR [GenericFileOnCompletion]
>> > Cannot store file: /tmp/trailer/.inprogress_trailer_test.mpg
>> > org.apache.camel.component.file.GenericFileOperationFailedException:
>> > Cannot
>> > store file: /tmp/trailer/.inprogress_trailer_test.mpg
>> >        at
>> >
>> > org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:203)
>> >        at
>> >
>> > org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:144)
>> >        at
>> >
>> > org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:86)
>> >        at
>> >
>> > org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:57)
>> >        at
>> >
>> > org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:81)
>> >        at
>> >
>> > org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:79)
>> >        at
>> > org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:141)
>> >        at
>> > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:78)
>> >        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:70)
>> >        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.processor.SendProcessor$1.doInProducer(SendProcessor.java:81)
>> >        at
>> >
>> > org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:79)
>> >        at
>> > org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:141)
>> >        at
>> > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:78)
>> >        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.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:198)
>> >        at
>> >
>> > org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120)
>> >        at
>> >
>> > org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93)
>> >        at
>> >
>> > org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99)
>> >        at
>> > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
>> >        at
>> >
>> > java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
>> >        at
>> > java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
>> >        at
>> >
>> > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
>> >        at
>> >
>> > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)
>> >        at
>> >
>> > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)
>> >        at
>> >
>> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>> >        at
>> >
>> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>> >        at java.lang.Thread.run(Thread.java:613)
>> > Caused by: org.apache.camel.InvalidPayloadException: No body available
>> > of
>> > type: java.io.InputStream but has value: [bean:trailerHandler] of type:
>> > java.util.ArrayList on: Message: [bean:trailerHandler]. Caused by: No
>> > type
>> > converter available to convert from type: java.util.ArrayList to the
>> > required type: java.io.InputStream with value [bean:trailerHandler] on
>> > the
>> > exchange: Exchange[Message: [bean:trailerHandler]]
>> >        at
>> >
>> > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:104)
>> >        at
>> >
>> > org.apache.camel.util.ExchangeHelper.getMandatoryInBody(ExchangeHelper.java:136)
>> >        at
>> >
>> > org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:197)
>> >        ... 43 more
>> > Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
>> > converter available to convert from type: java.util.ArrayList to the
>> > required type: java.io.InputStream with value [bean:trailerHandler]
>> >        at
>> >
>> > org.apache.camel.impl.converter.DefaultTypeConverter.mandatoryConvertTo(DefaultTypeConverter.java:119)
>> >        at
>> >
>> > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:102)
>> >        ... 45 more
>> >
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Read more…
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to