One Star

tJava component exception stops the job

Hi all,
I did search through talend forums and other blogs but I couldn't came across something that was helpful to me. Here is my use case:
I have created a job where it listens for an xml file in a dir, move it to a working dir and then my tXSLT component transforms it into a json file. I read that json file using the tFileInputJSON component and pass it on to a tJava component (some java code loaded as a library) that parses the file and groups the json objects and then inserts them into some mysql tables. So my java code is actually managing the mysql connections and all the insertions. All working good for me.
Problem:
======
Though I am catching a bunch of exceptions within java code, but occasionally for certain scenarios an exception would happen and it would cause the job to die. How can I catch these exceptions so that it doesn't stop the actual job? Any input or feedback would be greatly appreciated.
Thanks,
Asher.
3 REPLIES
Moderator

Re: tJava component exception stops the job

Hi,
Would you mind uploading your job design screenshots into forum so that we can address your issue quickly.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: tJava component exception stops the job

Still have this problem and would appreciate any input..Thanks.

Files from the drop directory and moved over to working directory. The files in the working directory are transformed into json files and written to some directory location. If anything goes wrong here, the file gets put in the error directory (tFileCopy_1). I know nothing is going wrong here. The json file then gets parsed for data and that data gets inserted into database tables. Here occasionally some exceptions may occur with the file being processed and if it happens the file gets moved to the error directory. However, the job gets stopped and we have to restart it every time. How can this be avoided if possible.??
Community Manager

Re: tJava component exception stops the job

Hi 
Though I am catching a bunch of exceptions within java code, but occasionally for certain scenarios an exception would happen and it would cause the job to die. How can I catch these exceptions so that it doesn't stop the actual job? Any input or feedback would be greatly appreciated.

You need to redesign the job like this:
main job:
....
 |
onsubjobok
 |
tFileList--iterate--tFileJsonInput--main--tFlowToIterate--iterate--tRunJob
on tRunJob: pass the current data to child job, and uncheck the 'die on error' option to ensure the main job will continue to run even though an exception occurs in the child job. 
Child job:
tFixedFlowInput--main--tJava
tFixedFlowInput: generate the current data.
How to pass the current data to child job, see this KB article:
https://help.talend.com/search/all?query=Passing+a+value+from+a+parent+Job+to+a+child+Job&content-la...
I hope this job could give you some hints to achieve your request.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business