One Star

raise and catch 'File Not Found' Exception

HI,
My job looks similar to the below.
tfilelist --(Iterate) -->tfileinputdelimited --(main)--> tmap --(main)--> staging_tbl (subjob1)
| \ ^
| (subjobok) \ (reject) | (lookup)
| \ dim1
| reject table
v
(subjob2)
|
|
v
other subjobs
:
:
I would like to raise and catch the 'File Not Found' exception if the expected file is not available in the directory, but I am not getting any error Smiley Indifferent. Please advice.
Thank you.
13 REPLIES
One Star

Re: raise and catch 'File Not Found' Exception

Hi
Which version of TOS do you use?
I'm using TOS 5.1.1 and the component tFileList can generate error when no file found.
Regards,
Pedro
One Star

Re: raise and catch 'File Not Found' Exception

Hi,
The 'File name' is coming from a database table which in turn assigned to a context variable.
The directory name is coming from the context variable.
We are using TOS 4.1.2

connecting to socket on port 3895
connected
Exception in component tFileInputDelimited_2
java.io.FileNotFoundException:

Getting the above error if my job starts with tfileinputdelimited instead of tfilelist.
Thank you.
One Star

Re: raise and catch 'File Not Found' Exception

Hi
Maybe I know the reason now.
What do you mean "the expected file is not available in the directory"?
The option "Generate error if no file found" indicates that only the file doesn't exist in this directory. It will generate error.
Well. If the file exists in this directory and it cannot be accessed, the error won't occur.
Maybe you get a wrong understanding about this option?
Or. You might try to update your TOS version. TOS 4.1.2 is relatively old...
Regards,
Pedro
One Star

Re: raise and catch 'File Not Found' Exception

Hi Pedro,
I have created the job to process the file 'TAL_TEST.TXT'. As stated before the file name is assigned to a context variable from the database table. The directory name is coming from the context variable.
In case the file 'TAL_TEST.TXT' is not available in the directory, I presume the job should abend and an exception should be raised. Everything works perfectly well if my job starts with tfileinputdelimited.
When I use the tfilelist --(Iterate) -->tfileinputdelimited the job is not producing any error OR is that how the tfilelist component works, if the file is not available it will continue processing. In our case the filemask will be the actual file name from the context, thus we are processing the whole job just for one file.
Hope I am clear with my issue.
Thank you.
One Star

Re: raise and catch 'File Not Found' Exception

Hi
Finally, got you...
The usages of tFileInputDelimited and tFileList are apparently different.
Why don't you select the option "generate error when no file found" on tFileList?
It would show you the following exception when no file found.
java.lang.RuntimeException: No file found in directory F:/TOS_DI-r84309-V5.1.1/workspace
Regards,
Pedro
One Star

Re: raise and catch 'File Not Found' Exception

Thanks Pedro,
I just noticed the check box Generate Error if no file found. However, can't the exception be caught and handled with custom message.
One Star

Re: raise and catch 'File Not Found' Exception

Hi
Sorry. You can't use the custom message here.
Regards,
Pedro
One Star

Re: raise and catch 'File Not Found' Exception

Thanks for the clarification Pedro.
One Star

Re: raise and catch 'File Not Found' Exception

hi,

I want all details about a job start time,processing status,error message and reason for execution failure stop time ,total execution time,job completion status ,like this all information relating to a job to be written from tool to a database. Is it possible ? If yes ,give the sample job to achieve this scenario.

with regards,
banu
One Star

Re: raise and catch 'File Not Found' Exception

Hi!
Here is the link on the tutorial that may help you to receive all the information you want.
http://www.talendforge.org/tutorials/tutorial.php?idTuto=31
Please send feedback if this is what you're looking for.
tnx
Best regards!
LadyButterfly
One Star

Re: raise and catch 'File Not Found' Exception

hi,

It was useful Smiley Happy , but what i want is does tool have variable that give details about job execution ,the stack trace which prints on console should be given in variable so we can keep a record of what has happened to job in database.
One Star

Re: raise and catch 'File Not Found' Exception

Hi!
I looked up for list of global variables in tJava component (ctrl+space) which have all Talend Jobs, but there is nothing useful Smiley Sad
If you find the way to see all the job details, let me now the procedure to achieve it.
TNX
Best regards,
Lady Butterfly
One Star

Re: raise and catch 'File Not Found' Exception