You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by watcher <pa...@daly.ws> on 2008/12/17 15:42:18 UTC

FileComponent FileNotFoundException

I'm noticed an intermittent exception be thrown in my application. It usually
happens after uploading a large file. It seems to happen whenever the
fileConsumer is attempting to poll a file that is been written too. 
I expected the fileConsumer only to poll the file when it has an
exclusiveReadLock on the file.

I can replicate the problem by dropping a file into the server and quickly
opening the file with excel. ( This will hold a lock on the file) after 30
secs or so the exception is thrown.

<code>
java.io.FileNotFoundException:
c:\temp\File_20081120_17-Dec-2008_14-15-59.txt (The
process cannot access the file because it is being used by another process)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
        at
org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
04)
        at
org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:143)
        at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:89)
        at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:99)
        at
org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:65)
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Scheduled
ThreadPoolExecutor.java:98)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Schedule
dThreadPoolExecutor.java:181)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadP
oolExecutor.java:205)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
</code>

I had hope that after releasing the lock on the file (closing excel) the
fileConsumer would retry the poll.
However the file remains on the c:\\temp directory. Should the file
component not retry up to 6 times from my setup below.


errorHandler(deadLetterChannel("activemq:queue:errors").maximumRedeliveries(6).initialRedeliveryDelay(5000)); 

from("file://c://temp?delete=true&consumer.delay=30000&consumer.alwaysConsume=true&consumer.exclusiveReadLock=true").to("ftp://username@localhost?password=pass;binary=true)

Camel 1.5.0

Many Thanks
-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21054406.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I am running the catch IOException as unit tests now on Camel 2.0.

So if any of you guys is bored during the x-mas you could test the
Camel 2.0 camel-core.jar to see if it can handle the MS Office test ;)
Beware it have new URI options for setting the read lock. By default
it uses FileLock as Camel 1.x does.



On Fri, Dec 19, 2008 at 11:03 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Fri, Dec 19, 2008 at 10:53 AM, Ramon Buckland
> <ra...@gmail.com> wrote:
>> Yes the AV could do it also .. (you are correct, it is not just *.doc, *.xls
>> etc).
>>
>> Always a big culprit (the AV scanner)
> I guess we could add support for try .. catch (IOException) in Camel
> 2.0 for the read locks. As we now have timeout support as well you can
> set eg 5000 millis as timeout.
> If the lock couldn't be granted then Camel will retry again on the next poll().
>
>
>
>>
>>
>> On Fri, Dec 19, 2008 at 20:44, watcher <pa...@daly.ws> wrote:
>>
>>>
>>> Great. Will give it a go over the weekend.
>>> Associating microsofts products ( xls , doc etc ) with wordpad seems to get
>>> over the problem.
>>> It looks like these files create a temporary file for recovery purposes.
>>>
>>> However on our test server the file in question was a txt file that threw a
>>> FileNotFoundException.
>>> Maybe anti virus was running?
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>> >
>>> > On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
>>> >>
>>> >> Yeah, I tried opening a txt file with wordpad and notepad and had no
>>> >> problems.
>>> >>
>>> >> Associating a txt file with Excel will cause a problem.
>>> > For what is worth it, we have a new strategy in Camel 2.0 to use
>>> > rename instead of FileLock so that might work for this strange issue
>>> > with Excel.
>>> >
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> Thanks Claus. Enjoy the xmas break and have a happy new year.
>>> > You too.
>>> >
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
>>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> > /Claus Ibsen
>>> > Apache Camel Committer
>>> > Blog: http://davsclaus.blogspot.com/
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21088466.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Dec 19, 2008 at 10:53 AM, Ramon Buckland
<ra...@gmail.com> wrote:
> Yes the AV could do it also .. (you are correct, it is not just *.doc, *.xls
> etc).
>
> Always a big culprit (the AV scanner)
I guess we could add support for try .. catch (IOException) in Camel
2.0 for the read locks. As we now have timeout support as well you can
set eg 5000 millis as timeout.
If the lock couldn't be granted then Camel will retry again on the next poll().



>
>
> On Fri, Dec 19, 2008 at 20:44, watcher <pa...@daly.ws> wrote:
>
>>
>> Great. Will give it a go over the weekend.
>> Associating microsofts products ( xls , doc etc ) with wordpad seems to get
>> over the problem.
>> It looks like these files create a temporary file for recovery purposes.
>>
>> However on our test server the file in question was a txt file that threw a
>> FileNotFoundException.
>> Maybe anti virus was running?
>>
>>
>>
>> Claus Ibsen-2 wrote:
>> >
>> > On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
>> >>
>> >> Yeah, I tried opening a txt file with wordpad and notepad and had no
>> >> problems.
>> >>
>> >> Associating a txt file with Excel will cause a problem.
>> > For what is worth it, we have a new strategy in Camel 2.0 to use
>> > rename instead of FileLock so that might work for this strange issue
>> > with Excel.
>> >
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Thanks Claus. Enjoy the xmas break and have a happy new year.
>> > You too.
>> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> >
>> > /Claus Ibsen
>> > Apache Camel Committer
>> > Blog: http://davsclaus.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21088466.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by Ramon Buckland <ra...@gmail.com>.
Yes the AV could do it also .. (you are correct, it is not just *.doc, *.xls
etc).

Always a big culprit (the AV scanner)


On Fri, Dec 19, 2008 at 20:44, watcher <pa...@daly.ws> wrote:

>
> Great. Will give it a go over the weekend.
> Associating microsofts products ( xls , doc etc ) with wordpad seems to get
> over the problem.
> It looks like these files create a temporary file for recovery purposes.
>
> However on our test server the file in question was a txt file that threw a
> FileNotFoundException.
> Maybe anti virus was running?
>
>
>
> Claus Ibsen-2 wrote:
> >
> > On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
> >>
> >> Yeah, I tried opening a txt file with wordpad and notepad and had no
> >> problems.
> >>
> >> Associating a txt file with Excel will cause a problem.
> > For what is worth it, we have a new strategy in Camel 2.0 to use
> > rename instead of FileLock so that might work for this strange issue
> > with Excel.
> >
> >>
> >>
> >>
> >>
> >>
> >> Thanks Claus. Enjoy the xmas break and have a happy new year.
> > You too.
> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> >
> > --
> >
> > /Claus Ibsen
> > Apache Camel Committer
> > Blog: http://davsclaus.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21088466.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: FileComponent FileNotFoundException

Posted by watcher <pa...@daly.ws>.
Great. Will give it a go over the weekend.
Associating microsofts products ( xls , doc etc ) with wordpad seems to get
over the problem.
It looks like these files create a temporary file for recovery purposes.

However on our test server the file in question was a txt file that threw a
FileNotFoundException.
Maybe anti virus was running?



Claus Ibsen-2 wrote:
> 
> On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
>>
>> Yeah, I tried opening a txt file with wordpad and notepad and had no
>> problems.
>>
>> Associating a txt file with Excel will cause a problem.
> For what is worth it, we have a new strategy in Camel 2.0 to use
> rename instead of FileLock so that might work for this strange issue
> with Excel.
> 
>>
>>
>>
>>
>>
>> Thanks Claus. Enjoy the xmas break and have a happy new year.
> You too.
> 
>>
>> --
>> View this message in context:
>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21088466.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Ramon Buckland <ra...@gmail.com>.
This problem will also happen under Word and other apps on Windows, I
suspect, where a special Read-Lock is obtained (by that app).

I have noted (yet not proven in a test that)
    - try catch around a from("file://...") does not catch the exception (as
the file poller never starts :-/ )
    - onException before the file:// poller does not catch it either (as it
happens I assume, before any message is created).
    - this may be replicable if the file were listable in UNIX in a dir
(drwx), but not readable (--wx) for eg.

I have wanted to create a test case for each of these and then deal with it
but time and christmas :-) ..
r

On Fri, Dec 19, 2008 at 20:30, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
> >
> > Yeah, I tried opening a txt file with wordpad and notepad and had no
> > problems.
> >
> > Associating a txt file with Excel will cause a problem.
> For what is worth it, we have a new strategy in Camel 2.0 to use
> rename instead of FileLock so that might work for this strange issue
> with Excel.
>
> >
> >
> >
> >
> >
> > Thanks Claus. Enjoy the xmas break and have a happy new year.
> You too.
>
> >
> > --
> > View this message in context:
> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>

Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 18, 2008 at 9:41 PM, watcher <pa...@daly.ws> wrote:
>
> Yeah, I tried opening a txt file with wordpad and notepad and had no
> problems.
>
> Associating a txt file with Excel will cause a problem.
For what is worth it, we have a new strategy in Camel 2.0 to use
rename instead of FileLock so that might work for this strange issue
with Excel.

>
>
>
>
>
> Thanks Claus. Enjoy the xmas break and have a happy new year.
You too.

>
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by watcher <pa...@daly.ws>.
Yeah, I tried opening a txt file with wordpad and notepad and had no
problems.

Associating a txt file with Excel will cause a problem. 





Thanks Claus. Enjoy the xmas break and have a happy new year.

-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21080535.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Thanks for sharing this. Kinda strange .xls is locked while .csv is not.
If the file is .csv it's not as if Excel will temporary rename it
while it has it open?

Could you try other applications to lock the file, for instance
WordPad or whatever text editor. etc.

I am leaving for early x-mas to areas where internet might not be
accessible. So I might not be back before 2nd Jan 2009.


On Thu, Dec 18, 2008 at 8:52 PM, watcher <pa...@daly.ws> wrote:
>
> Hi Claus
>
> Thanks for that.
> I was able to reproduce the problem using the unit test below.
> It seems that the test passes if you use a file with the extension .xls
> saving the file as a csv will cause a FileNotFoundException
>
>
> Claus Ibsen-2 wrote:
>>
>> On Thu, Dec 18, 2008 at 10:49 AM, watcher <pa...@daly.ws> wrote:
>>>
>>>  I'm testing on WindowsXP with NTFS.
>>> Is there anything else I should try.
>>>
>>> I wont be able to work on this until tonight.
>> Here is the unit test that I run. I open the excel file before
>> starting the unit test.
>>
>> /**
>>  * Unit test to verify exclusive read by for manual testing.
>>  */
>> public class FileExclusiveReadManuelTest extends ContextTestSupport {
>>
>>     private String fileUrl = "file://target/exclusiveread";
>>
>>     @Override
>>     protected void setUp() throws Exception {
>>         disableJMX();
>>         super.setUp();
>>     }
>>
>>     public void testManually() throws Exception {
>>         deleteDirectory("./target/exclusiveread");
>>         MockEndpoint mock = getMockEndpoint("mock:result");
>>         mock.setSleepForEmptyTest(10000);
>>         mock.expectedMessageCount(0);
>>
>>         mock.assertIsSatisfied();
>>     }
>>
>>     protected RouteBuilder createRouteBuilder() throws Exception {
>>         return new RouteBuilder() {
>>             public void configure() throws Exception {
>>                 from(fileUrl).to("mock:result");
>>             }
>>         };
>>     }
>>
>>
>> Notice the setSleepForEmptyTest is currently not working in 1.5.0. So
>> you should do Thread.sleep(10000) instead.
>>
>>
>>
>>>
>>> Thanks
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> I just tried on my local system: WindowsXP with NTFS
>>>>
>>>>
>>>> It worked fine. I had an excel file opened and Camel waited for the
>>>> lock. I closed the excel and Camel instantly got the read lock and
>>>> continued to operate.
>>>>
>>>> Opening the file in Excel
>>>> ...
>>>> 07:15:48 = trying to get the lock
>>>> ...
>>>> Closing the file in Excel
>>>> ...
>>>> 07:15:55 = got the lock
>>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21069665.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21079746.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by watcher <pa...@daly.ws>.
Hi Claus

Thanks for that.
I was able to reproduce the problem using the unit test below.
It seems that the test passes if you use a file with the extension .xls
saving the file as a csv will cause a FileNotFoundException


Claus Ibsen-2 wrote:
> 
> On Thu, Dec 18, 2008 at 10:49 AM, watcher <pa...@daly.ws> wrote:
>>
>>  I'm testing on WindowsXP with NTFS.
>> Is there anything else I should try.
>>
>> I wont be able to work on this until tonight.
> Here is the unit test that I run. I open the excel file before
> starting the unit test.
> 
> /**
>  * Unit test to verify exclusive read by for manual testing.
>  */
> public class FileExclusiveReadManuelTest extends ContextTestSupport {
> 
>     private String fileUrl = "file://target/exclusiveread";
> 
>     @Override
>     protected void setUp() throws Exception {
>         disableJMX();
>         super.setUp();
>     }
> 
>     public void testManually() throws Exception {
>         deleteDirectory("./target/exclusiveread");
>         MockEndpoint mock = getMockEndpoint("mock:result");
>         mock.setSleepForEmptyTest(10000);
>         mock.expectedMessageCount(0);
> 
>         mock.assertIsSatisfied();
>     }
> 
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             public void configure() throws Exception {
>                 from(fileUrl).to("mock:result");
>             }
>         };
>     }
> 
> 
> Notice the setSleepForEmptyTest is currently not working in 1.5.0. So
> you should do Thread.sleep(10000) instead.
> 
> 
> 
>>
>> Thanks
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> I just tried on my local system: WindowsXP with NTFS
>>>
>>>
>>> It worked fine. I had an excel file opened and Camel waited for the
>>> lock. I closed the excel and Camel instantly got the read lock and
>>> continued to operate.
>>>
>>> Opening the file in Excel
>>> ...
>>> 07:15:48 = trying to get the lock
>>> ...
>>> Closing the file in Excel
>>> ...
>>> 07:15:55 = got the lock
>>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21069665.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21079746.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 18, 2008 at 10:49 AM, watcher <pa...@daly.ws> wrote:
>
>  I'm testing on WindowsXP with NTFS.
> Is there anything else I should try.
>
> I wont be able to work on this until tonight.
Here is the unit test that I run. I open the excel file before
starting the unit test.

/**
 * Unit test to verify exclusive read by for manual testing.
 */
public class FileExclusiveReadManuelTest extends ContextTestSupport {

    private String fileUrl = "file://target/exclusiveread";

    @Override
    protected void setUp() throws Exception {
        disableJMX();
        super.setUp();
    }

    public void testManually() throws Exception {
        deleteDirectory("./target/exclusiveread");
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.setSleepForEmptyTest(10000);
        mock.expectedMessageCount(0);

        mock.assertIsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from(fileUrl).to("mock:result");
            }
        };
    }


Notice the setSleepForEmptyTest is currently not working in 1.5.0. So
you should do Thread.sleep(10000) instead.



>
> Thanks
>
>
>
> Claus Ibsen-2 wrote:
>>
>> I just tried on my local system: WindowsXP with NTFS
>>
>>
>> It worked fine. I had an excel file opened and Camel waited for the
>> lock. I closed the excel and Camel instantly got the read lock and
>> continued to operate.
>>
>> Opening the file in Excel
>> ...
>> 07:15:48 = trying to get the lock
>> ...
>> Closing the file in Excel
>> ...
>> 07:15:55 = got the lock
>>
>
>
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21069665.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I am currently working on reworking the exclusive readlock for Camel 2.0.
I am refactoring it to allow pluggable strategies and also shipping
with another strategy that is rename based.
This allow you to use rename based instead of FileLock.

On Thu, Dec 18, 2008 at 10:49 AM, watcher <pa...@daly.ws> wrote:
>
>  I'm testing on WindowsXP with NTFS.
> Is there anything else I should try.
>
> I wont be able to work on this until tonight.
>
> Thanks
>
>
>
> Claus Ibsen-2 wrote:
>>
>> I just tried on my local system: WindowsXP with NTFS
>>
>>
>> It worked fine. I had an excel file opened and Camel waited for the
>> lock. I closed the excel and Camel instantly got the read lock and
>> continued to operate.
>>
>> Opening the file in Excel
>> ...
>> 07:15:48 = trying to get the lock
>> ...
>> Closing the file in Excel
>> ...
>> 07:15:55 = got the lock
>>
>
>
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21069665.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by watcher <pa...@daly.ws>.
 I'm testing on WindowsXP with NTFS.
Is there anything else I should try. 

I wont be able to work on this until tonight. 

Thanks



Claus Ibsen-2 wrote:
> 
> I just tried on my local system: WindowsXP with NTFS
> 
> 
> It worked fine. I had an excel file opened and Camel waited for the
> lock. I closed the excel and Camel instantly got the read lock and
> continued to operate.
> 
> Opening the file in Excel
> ...
> 07:15:48 = trying to get the lock
> ...
> Closing the file in Excel
> ...
> 07:15:55 = got the lock
> 


-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21069665.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
I just tried on my local system: WindowsXP with NTFS


It worked fine. I had an excel file opened and Camel waited for the
lock. I closed the excel and Camel instantly got the read lock and
continued to operate.

Opening the file in Excel
...
07:15:48 = trying to get the lock
...
Closing the file in Excel
...
07:15:55 = got the lock


2008-12-18 07:15:48,296 [mponent@110c424] DEBUG FileConsumer
        - Total 1 files to consume
2008-12-18 07:15:48,296 [mponent@110c424] TRACE FileConsumer
        - Processing file:
target\exclusiveread\Faktureringsgrundlag_ci_1kvartal_2007.xls
2008-12-18 07:15:48,312 [mponent@110c424] DEBUG FileEndpoint
        - Using file process strategy:
org.apache.camel.component.file.strategy.RenameFileProcessStrategy@1bf3d87
2008-12-18 07:15:48,312 [mponent@110c424] TRACE FileConsumer
        - Waiting for exclusive read lock to file:
target\exclusiveread\Faktureringsgrundlag_ci_1kvartal_2007.xls
2008-12-18 07:15:55,359 [mponent@110c424] TRACE FileConsumer
        - Acquired exclusive read lock:
sun.nio.ch.FileLockImpl[0:9223372036854775807 exclusive valid] to
file: target\exclusiveread\Faktureringsgrundlag_ci_1kvartal_2007.xls
2008-12-18 07:15:55,359 [mponent@110c424] DEBUG FileConsumer
        - About to process file:
target\exclusiveread\Faktureringsgrundlag_ci_1kvartal_2007.xls using
exchange: Exchange[FileMessage:
target\exclusiveread\Faktureringsgrundlag_ci_1kvartal_2007.xls]



On Thu, Dec 18, 2008 at 6:18 AM, Claus Ibsen <cl...@gmail.com> wrote:
> I created ticket to track this issue
> https://issues.apache.org/activemq/browse/CAMEL-1195
>
> On Thu, Dec 18, 2008 at 6:09 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> Thanks for the logging. We have a ticket in JIRA to allow a different
>> strategy for exclusive read locks. Currently we only use the java NIO
>> locks. But they do not work consistent on all file systems or not at
>> all. So another strategy is the good old rename the file before
>> reading. This is what we do with the FTP component.
>>
>> So I will see what I can do to get this fixed so you can use the other
>> strategy instead.
>>
>> I assume you use Windows XP? What file system do you use NTFS or FAT32?
>>
>>
>>
>> On Wed, Dec 17, 2008 at 11:12 PM, watcher <pa...@daly.ws> wrote:
>>>
>>> Hi Claus
>>>
>>> Here's the trace logs enabled. If I start may application with the file
>>> already opened in Excel. The error is generated below.
>>>
>>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>>> org.apache.camel.component.file.FileComponent@18be298] Fil
>>> eConsumer.pollFileOrDirectory(95) | Polling directory c:\temp
>>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>>> org.apache.camel.component.file.FileComponent@18be298] Fil
>>> eConsumer.pollFile(119) | Polling file: c:\temp\file.txt
>>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>>> org.apache.camel.component.file.FileComponent@18be298] Fil
>>> eConsumer.acquireExclusiveReadLock(200) | Waiting for exclusive read lock to
>>> file: c:\temp\file.txt
>>>
>>> 17 Dec 2008 22:03:01,484 ERROR [Thread: 1
>>> org.apache.camel.component.file.FileComponent@18be298] FileConsumer.log(188)
>>> | c:\temp\file.txt (The process cannot access the file because it is being u
>>> sed by another process)
>>> java.io.FileNotFoundException: c:\temp\file.txt (The process cannot access
>>> the file because it
>>> is being used by another process)
>>>        at java.io.RandomAccessFile.open(Native Method)
>>>        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>>>        at
>>> org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
>>> 04)
>>>
>>> --
>>> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21062702.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
I created ticket to track this issue
https://issues.apache.org/activemq/browse/CAMEL-1195

On Thu, Dec 18, 2008 at 6:09 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Thanks for the logging. We have a ticket in JIRA to allow a different
> strategy for exclusive read locks. Currently we only use the java NIO
> locks. But they do not work consistent on all file systems or not at
> all. So another strategy is the good old rename the file before
> reading. This is what we do with the FTP component.
>
> So I will see what I can do to get this fixed so you can use the other
> strategy instead.
>
> I assume you use Windows XP? What file system do you use NTFS or FAT32?
>
>
>
> On Wed, Dec 17, 2008 at 11:12 PM, watcher <pa...@daly.ws> wrote:
>>
>> Hi Claus
>>
>> Here's the trace logs enabled. If I start may application with the file
>> already opened in Excel. The error is generated below.
>>
>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>> org.apache.camel.component.file.FileComponent@18be298] Fil
>> eConsumer.pollFileOrDirectory(95) | Polling directory c:\temp
>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>> org.apache.camel.component.file.FileComponent@18be298] Fil
>> eConsumer.pollFile(119) | Polling file: c:\temp\file.txt
>> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
>> org.apache.camel.component.file.FileComponent@18be298] Fil
>> eConsumer.acquireExclusiveReadLock(200) | Waiting for exclusive read lock to
>> file: c:\temp\file.txt
>>
>> 17 Dec 2008 22:03:01,484 ERROR [Thread: 1
>> org.apache.camel.component.file.FileComponent@18be298] FileConsumer.log(188)
>> | c:\temp\file.txt (The process cannot access the file because it is being u
>> sed by another process)
>> java.io.FileNotFoundException: c:\temp\file.txt (The process cannot access
>> the file because it
>> is being used by another process)
>>        at java.io.RandomAccessFile.open(Native Method)
>>        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>>        at
>> org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
>> 04)
>>
>> --
>> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21062702.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Thanks for the logging. We have a ticket in JIRA to allow a different
strategy for exclusive read locks. Currently we only use the java NIO
locks. But they do not work consistent on all file systems or not at
all. So another strategy is the good old rename the file before
reading. This is what we do with the FTP component.

So I will see what I can do to get this fixed so you can use the other
strategy instead.

I assume you use Windows XP? What file system do you use NTFS or FAT32?



On Wed, Dec 17, 2008 at 11:12 PM, watcher <pa...@daly.ws> wrote:
>
> Hi Claus
>
> Here's the trace logs enabled. If I start may application with the file
> already opened in Excel. The error is generated below.
>
> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
> org.apache.camel.component.file.FileComponent@18be298] Fil
> eConsumer.pollFileOrDirectory(95) | Polling directory c:\temp
> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
> org.apache.camel.component.file.FileComponent@18be298] Fil
> eConsumer.pollFile(119) | Polling file: c:\temp\file.txt
> 17 Dec 2008 22:03:01,484 TRACE [Thread: 1
> org.apache.camel.component.file.FileComponent@18be298] Fil
> eConsumer.acquireExclusiveReadLock(200) | Waiting for exclusive read lock to
> file: c:\temp\file.txt
>
> 17 Dec 2008 22:03:01,484 ERROR [Thread: 1
> org.apache.camel.component.file.FileComponent@18be298] FileConsumer.log(188)
> | c:\temp\file.txt (The process cannot access the file because it is being u
> sed by another process)
> java.io.FileNotFoundException: c:\temp\file.txt (The process cannot access
> the file because it
> is being used by another process)
>        at java.io.RandomAccessFile.open(Native Method)
>        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>        at
> org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
> 04)
>
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21062702.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: FileComponent FileNotFoundException

Posted by watcher <pa...@daly.ws>.
Hi Claus

Here's the trace logs enabled. If I start may application with the file
already opened in Excel. The error is generated below.

17 Dec 2008 22:03:01,484 TRACE [Thread: 1
org.apache.camel.component.file.FileComponent@18be298] Fil
eConsumer.pollFileOrDirectory(95) | Polling directory c:\temp
17 Dec 2008 22:03:01,484 TRACE [Thread: 1
org.apache.camel.component.file.FileComponent@18be298] Fil
eConsumer.pollFile(119) | Polling file: c:\temp\file.txt
17 Dec 2008 22:03:01,484 TRACE [Thread: 1
org.apache.camel.component.file.FileComponent@18be298] Fil
eConsumer.acquireExclusiveReadLock(200) | Waiting for exclusive read lock to
file: c:\temp\file.txt

17 Dec 2008 22:03:01,484 ERROR [Thread: 1
org.apache.camel.component.file.FileComponent@18be298] FileConsumer.log(188)
| c:\temp\file.txt (The process cannot access the file because it is being u
sed by another process)
java.io.FileNotFoundException: c:\temp\file.txt (The process cannot access
the file because it
is being used by another process)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
        at
org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
04)

-- 
View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21062702.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FileComponent FileNotFoundException

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 17, 2008 at 3:42 PM, watcher <pa...@daly.ws> wrote:
>
> I'm noticed an intermittent exception be thrown in my application. It usually
> happens after uploading a large file. It seems to happen whenever the
> fileConsumer is attempting to poll a file that is been written too.
> I expected the fileConsumer only to poll the file when it has an
> exclusiveReadLock on the file.
>
> I can replicate the problem by dropping a file into the server and quickly
> opening the file with excel. ( This will hold a lock on the file) after 30
> secs or so the exception is thrown.
>
> <code>
> java.io.FileNotFoundException:
> c:\temp\File_20081120_17-Dec-2008_14-15-59.txt (The
> process cannot access the file because it is being used by another process)
>        at java.io.RandomAccessFile.open(Native Method)
>        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>        at
> org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
> 04)
>        at
> org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:143)
>        at
> org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:89)
>        at
> org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:99)
>        at
> org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:65)
>        at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
>        at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>        at
> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
>        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Scheduled
> ThreadPoolExecutor.java:98)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Schedule
> dThreadPoolExecutor.java:181)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadP
> oolExecutor.java:205)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:619)
> </code>
>
> I had hope that after releasing the lock on the file (closing excel) the
> fileConsumer would retry the poll.
> However the file remains on the c:\\temp directory. Should the file
> component not retry up to 6 times from my setup below.
The error handle kick is when the file exchange has been created and
is processed in the routing. So it's working after the from. However
you have configured the file consumer to run again after 30 sec, so
the file will be picked up this 2nd time then.

It will retry the .to part in your route up till 6 times, so if the
ftp producer can not upload the file it will retry.

Can you enable TRACE logging for org.apache.camel.component.file
It will spit a bit more out in the log. I would like to see why the
NIO lock() throws FileNotFoundException and doesn't wait for the lock
to be granted.



>
>
> errorHandler(deadLetterChannel("activemq:queue:errors").maximumRedeliveries(6).initialRedeliveryDelay(5000));
>
> from("file://c://temp?delete=true&consumer.delay=30000&consumer.alwaysConsume=true&consumer.exclusiveReadLock=true").to("ftp://username@localhost?password=pass;binary=true)
>
> Camel 1.5.0
>
> Many Thanks
> --
> View this message in context: http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21054406.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/