Hi

When using files on windows, make sure that if you use any custom code
that read the file using a stream ,such af FileInputStream, etc. you
must close the stream.

On windows the file cannot be moved/deleted if that occurs. So double
check your own code first.


On Fri, Jul 6, 2012 at 1:55 PM, Aida <ai.d...@gmail.com> wrote:
> Hello,
>
> I'm having trouble when working with producerTemplate and consumerTemplate
> in the following scenary:
>
> 1. I read a file from a local directory with a consumerTemplate. The only
> options I'm using are: {fileName, charset, intialDelay, delay}
> 2. I copy that file to an ftp directory using a producerTemplate.
>
> At the end of the process, the source file (the one that I read from a local
> directory) is not deleted. If in the second step I use a file component
> instead of an ftp component it works as expected.
>
> When the file is not deleted, I have this trace in the console:
> 2012-07-06 13:35:40,815 WARN
> [org.apache.camel.component.file.GenericFileOnCompletion] - Caused by:
> [org.apache.camel.component.file.GenericFileOperationFailedException - Error
> renaming file from
> C:\desarrollo\sources\energy-template\processes\camel\target\testProcessAndDelete\file.txt
> to target\testProcessAndDelete\.camel\file.txt]
> org.apache.camel.component.file.GenericFileOperationFailedException: Error
> renaming file from
> C:\desarrollo\sources\energy-template\processes\camel\target\testProcessAndDelete\file.txt
> to target\testProcessAndDelete\.camel\file.txt
>         at
> org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:72)
>         at
> org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport.renameFile(GenericFileProcessStrategySupport.java:107)
>         at
> org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:86)
>         at
> org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:132)
>         at
> org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:82)
> ...
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.io.IOException: Renaming file from:
> C:\desarrollo\sources\energy-template\processes\camel\target\testProcessAndDelete\file.txt
> to: target\testProcessAndDelete\.camel\file.txt failed due cannot delete
> from file:
> C:\desarrollo\sources\energy-template\processes\camel\target\testProcessAndDelete\file.txt
> after copy succeeded
>         at org.apache.camel.util.FileUtil.renameFile(FileUtil.java:362)
>         at
> org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:70)
>         ... 94 more
>
>
>
> If I set the option delete=true then the beggining of the trace is this one:
> 2012-07-06 13:34:45,199 WARN
> [org.apache.camel.component.file.GenericFileOnCompletion] - Caused by:
> [org.apache.camel.component.file.GenericFileOperationFailedException -
> Cannot delete file: GenericFile[file.txt]]
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
> delete file: GenericFile[file.txt]
>         at
> org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:82)
>         at
> org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:132)
>         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)
> ...
>
>
> I attach a simple test that reproduces what is happening to me (the only
> thing that the test needs to work is to change the ftp endpoint
> configuration apart from editing the package of the class).
>
> I have been thinking that using a bean that uses the
> org.apache.camel.util.FileUtil to explicity delete the file would be an
> option, but since camel It's supposed to do that and in the trace I have
> seen that camel already uses that library I donĀ“t know which is the better
> way to do this.
>
> Thanks in advance.
>
> Attachment:
> http://camel.465427.n5.nabble.com/file/n5715615/FileConsumingTest.java
> FileConsumingTest.java
>
>   Aida.
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/file2-ftp2-Source-file-not-deleted-after-using-a-combination-of-file2-component-and-ftp2-component-ws-tp5715615.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to