You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bocamel <jo...@gmail.com> on 2013/09/05 19:34:48 UTC

Re: File renaming problems under Windows

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.

Re: File renaming problems under Windows

Posted by bocamel <jo...@gmail.com>.
Christian,

I tested this under Camel 2.12.0 and the issue that I reported did not
occur.  Thank you very much for fixing it!

FYI.  This is the first time I tried Camel 2.12.0.  Eclipse complained about
" The method getTextContent() is undefined for the type Node”
(org.w3c.dom.Node) unless I move JDK ahead of my Maven dependencies in the
buildpath.  The only thing changed in the Maven dependencies is Camel
ungraded from 2.11.1 to 2.12.0.

Thanks!




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

Re: File renaming problems under Windows

Posted by bocamel <jo...@gmail.com>.
Done... JIRA Camel-6756 was opened.



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

Re: File renaming problems under Windows

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Sep 12, 2013 at 11:06 PM, bocamel <jo...@gmail.com> wrote:
> Christian,
>
> I am afraid my celebration of the fix might be a little premature. :-).
> This failure of renaming/deleting a consumed file error still occurs when I
> forced a org.apache.camel.component.bean.AmbiguousMethodCallException in the
> route.  In other words, if the route receives a file from file consumer and
> sends it to a bean (having similar methods) that may result the above
> exception, then the File component cannot delete/rename the file.  I have
> been able to reproduce this issue consistently.
>

Thanks for reporting. Please feel free to log a JIRA ticket.


> Unfortunately in this case, since I am processing Excel files (binary
> format), I cannot try to convert the file into String first to see whether
> the problem will go away.
>
> Here is the route:
>
>                 <camel:route id="route-process-row">
>                         <camel:from uri="file:src/data/rowfile" />
>                         <camel:to uri="bean:converter" />
>                         <camel:onException>
> <camel:exception>org.apache.camel.component.bean.AmbiguousMethodCallException</camel:exception>
>                                 <camel:handled><constant>true</constant></camel:handled>
>                                 <camel:log message="*** Exception caught ***" />
>                         </camel:onException>
>                         <camel:onException>
>                                 <camel:exception>java.lang.RuntimeException</camel:exception>
>                                 <camel:handled><constant>true</constant></camel:handled>
>                                 <camel:log message="*** Exception caught ***" />
>                         </camel:onException>
>                 </camel:route>
>
> The two methods of bean:converter are:
> public ExternalDoc processRowExcelDoc(@Body InputStream body,
> @Header("CamelFileNameOnly") String fn)
> and
> public ExternalDoc processColExcelDoc(@Body InputStream body,
> @Header("CamelFileNameOnly") String fn)
>
> Thanks for any help you may provide!
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-renaming-problems-under-Windows-tp5719484p5739283.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: File renaming problems under Windows

Posted by bocamel <jo...@gmail.com>.
Christian, 

I am afraid my celebration of the fix might be a little premature. :-). 
This failure of renaming/deleting a consumed file error still occurs when I
forced a org.apache.camel.component.bean.AmbiguousMethodCallException in the
route.  In other words, if the route receives a file from file consumer and
sends it to a bean (having similar methods) that may result the above
exception, then the File component cannot delete/rename the file.  I have
been able to reproduce this issue consistently.

Unfortunately in this case, since I am processing Excel files (binary
format), I cannot try to convert the file into String first to see whether
the problem will go away.

Here is the route:

		<camel:route id="route-process-row">
			<camel:from uri="file:src/data/rowfile" />
			<camel:to uri="bean:converter" />
			<camel:onException>		
<camel:exception>org.apache.camel.component.bean.AmbiguousMethodCallException</camel:exception>
				<camel:handled><constant>true</constant></camel:handled>
				<camel:log message="*** Exception caught ***" />
			</camel:onException>
			<camel:onException>
				<camel:exception>java.lang.RuntimeException</camel:exception>
				<camel:handled><constant>true</constant></camel:handled>
				<camel:log message="*** Exception caught ***" />
			</camel:onException>
		</camel:route>

The two methods of bean:converter are:
public ExternalDoc processRowExcelDoc(@Body InputStream body,
@Header("CamelFileNameOnly") String fn)
and
public ExternalDoc processColExcelDoc(@Body InputStream body,
@Header("CamelFileNameOnly") String fn)

Thanks for any help you may provide!





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

Re: File renaming problems under Windows

Posted by Christian Müller <ch...@gmail.com>.
I think we fixed an issue in Camel 2.12.0 which could be related to this.
Can you give it a try? Camel 2.12.0 was released one day ago...

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Thu, Sep 5, 2013 at 7:34 PM, bocamel <jo...@gmail.com> wrote:

> 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.
>