I ran into a similar problem.  My use case is slightly different and I am
using Camel 2.11.1 and JDK 1.7.  But the result is that Camel cannot delete
the file from the input folder and keeps processing it indefinitely.

I have two routes.  The first route reads in XML files from a directory then
puts them on SEDA. The second route retrieves the files from SEDA and sends
them to a web services (CXF).  

      <camel:route id="CustomerXmlFileIn" >
         <camel:from uri="file:/xmlInput" />            
         <camel:to uri="seda:processCustomerInput" />
      </camel:route>   

and 

      <camel:route id="ProcessCustomerMessage"
errorHandlerRef="DeadLetterErrorHandler">
         <camel:from uri="seda:processCustomerInput" />
         <camel:to uri="cxf:bean:webSvcEndpoint" />
                 <camel:onException>
                        <camel:exception>java.lang.Exception</camel:exception>
                                
<camel:handled><camel:constant>true</camel:constant></camel:handled>    
                                <camel:log message="*** Error occurred 
processing file
${headers.CamelFileName}. ***" />
                                <camel:log 
message="${property.CamelExceptionCaught}" />
                 </camel:onException>         
      </camel:route>

Everything works fine until a non-XML file (bad.xml) is thrown into the
xmlInput folder.  The CXF endpoint throws the following exception.  When
this happens, route1 cannot delete the bad.xml file from the xmlInput. 
Camel keeps picking it up and the same error repeats indefinitely.

org.apache.camel.InvalidPayloadException: No body available of type:
org.apache.camel.component.cxf.CxfPayload but has value:
GenericFile[M:\bad.xml] of type: org.apache.camel.component.file.GenericFile
on: null. Caused by: Error during type conversion from type:
org.apache.camel.component.file.GenericFile to the required type:
org.apache.camel.component.cxf.CxfPayload with value GenericFile[M:\bad.xml]
due org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 2; Content
is not allowed in prolog.. Exchange[null]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: org.apache.camel.component.file.GenericFile to the required type:
org.apache.camel.component.cxf.CxfPayload with value GenericFile[M:\bad.xml]
due org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 2; Content
is not allowed in prolog.]

It is followed by the file deletion error:

2013-09-05 13:01:53,469 [ssCustomerInput] WARN  GenericFileOnCompletion       
- Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException - Error
renaming file from M:\bad.xml to M:\.camel\bad.xml]
org.apache.camel.component.file.GenericFileOperationFailedException: Error
renaming file from M:\bad.xml to M:\.camel\bad.xml
        at
org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:72)
        at
org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport.renameFile(GenericFileProcessStrategySupport.java:113)
        at
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:88)
        at
org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:144)
        at
org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:82)
        at
org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:53)
        at
org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:55)
        at 
org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:226)
        at
org.apache.camel.processor.UnitOfWorkProcessor.doneUow(UnitOfWorkProcessor.java:199)
        at
org.apache.camel.processor.UnitOfWorkProcessor.access$000(UnitOfWorkProcessor.java:37)
        at
org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:157)
        at
org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
        at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
        at
org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
        at
org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:294)
        at
org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:203)
        at 
org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:150)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Renaming file from: M:\bad.xml to:
M:\.camel\bad.xml failed due cannot delete from file: M:\bad.xml after copy
succeeded
        at org.apache.camel.util.FileUtil.renameFile(FileUtil.java:397)
        at
org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:70)
        ... 29 more

I can avoid this problem by first converting the body to String in route1
before sending it to SEDA.  But if this is something can be fixed once for
all in Camel/CXF, it will make Camel more robust.  

Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/File-renaming-problems-under-Windows-tp5719484p5738801.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to