One Star

Getting the exception message of a subjob

Hi,
I have a job running another job with a tRunJob component and I would like to send an email when this job fails.
So I'm using a tSendMail with an OnSubjobError trigger.
I set the content of the mail to ((String)globalMap.get("tRunJob_1_ERROR_MESSAGE"))
but unfortunately, this retrieves only a generic message like: 'Child job running failed'
I would like to get the corresponding exception message:
Exception in ....
at ...
at ...
How can I do that ?
5 REPLIES
One Star

Re: Getting the exception message of a subjob

Hi,
What about the LogCatcher? There you could specify that Java exception should be catched. From there you can create a new flow like writing to a log or database as sending a mail, too.

Danny
One Star

Re: Getting the exception message of a subjob

Hi wizard, I still need some of your magic,
I've tried your solution but the LogCatcher returns something like this:
2009-04-21 12:21:47|WWS9MD|WWS9MD|WWS9MD|my_project|my_job|Default|6|Java Exception|tRunJob_1|Child job running failed|1
It contains an error message telling me that there was an exception, but it doesn't hold the exception message itself, I want to retrieve this:
Exception in component tJava_1
java.lang.ArithmeticException: / by zero
at my_project.test_0_1.test.tJava_1Process(test.java:159)
at my_project.test_0_1.test.runJobInTOS(test.java:301)
at my_project.test_0_1.test.runJob(test.java:229)
at my_project.my_job_0_1.my_job.tRunJob_1Process(my_job.java:1000)
at my_project.my_job_0_1.my_job.runJobInTOS(my_job.java:1462)
at my_project.my_job_0_1.my_job.main(my_job.java:1358)
Exception in component tRunJob_1
java.lang.RuntimeException: Child job running failed
Any idea ?
One Star

Re: Getting the exception message of a subjob

No Problem, I still have mana left ;-).
Let a JavaRow component be the target of the logCatcher with the following line of code:
System.out.println(globalMap.get(<input_row>.origin+"_CHILD_EXCEPTION_STACKTRACE"));
This should do the trick. The Stacktrace is saved in a the globalMap object. The key is a concatentation of the exceptionthrowing component an the final String upon.
One Star

Re: Getting the exception message of a subjob

Unfortunately, the option you are talking about seems to be available only in the milestone release of the TOS (http://www.talendforge.org/bugs/view.php?id=5409)
I'm using the latest stable release (3.0.4) and I cannot see the CHILD_EXCEPTION_STACKTRACE feature.
I really cannot use a milestone release in production...
Seventeen Stars

Re: Getting the exception message of a subjob

hi,
perhaps , if you have to use stable release , you can add variable in the code source like show
there
hope it help you
regards
laurent