How to show stacktrace on error when running from command-line?

One Star

How to show stacktrace on error when running from command-line?

When I run my job from the command-line (using the shell script), is there any way to make it show a stack trace of the error? All I get is:
Exception in component tSystem_1
Moderator

Re: How to show stacktrace on error when running from command-line?

Hi,
If you log into studio, there is a error which is located in <Talend Studio install path>/workspace/.metadata/. If not, the error log is kept in <Talend Studio install path>\configuration.

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: How to show stacktrace on error when running from command-line?

Hi. This is not an error when running the job within Talend (ie. through the UI). It's an error when I export the job as a standalone process and run it on its own, outside of Talend.
Moderator

Re: How to show stacktrace on error when running from command-line?

Hi,
Do you check the location of <Talend Studio install path>\configuration? When you run your job from the command-line (using the shell script).
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: How to show stacktrace on error when running from command-line?

Again, I'm running this on a machine that does NOT have Talend installed on it at all., so there is no <Talend Studio install path>.
I have exported my job with scripts (that Talend generates) and I am running the shell script that Talend created.
Moderator

Re: How to show stacktrace on error when running from command-line?

Hi,
Run the command line on your machine:
sh test.sh > error.log

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: How to show stacktrace on error when running from command-line?

It seems you still do not understand what I am asking for.
Again, there is no stack trace in the output to stdout, so redirecting it to a log file isn't going to do anything.
My original question was whether there was a way to reconfigure talend so that it would show the stack traces for the exceptions catch by the tLogCatcher. If you can tell me how to do that, then you will have answered my question.

Re: How to show stacktrace on error when running from command-line?

Hello,
Actually i am having the same problem.
I need to check the stack strace of error and even send an email with that error and respective stack trace.
tLogCatcher and tAssertCatcher, apparently, only gives u the error but not the stack strace.
Is there any way to "catch" a java exception with the respective stack strace?
Seventeen Stars

Re: How to show stacktrace on error when running from command-line?

Of course you can.
The tSystem component provides to catch both output streams of a process to get it as global variabale.
You can access the content as string while the job is running and after the job finished. It is necessary to setup the options Standard Output and error Output to: "to global variable"
Here an example (in case your component in the job is the first of tSystem components):
((String) globalMap.get("tSystem_1_OUTPUT")) returns the normal output
((String) globalMap.get("tSystem_1_ERROROUTPUT")) returns the error output content.
You can use the tParallel component to run your job and in parallel to it a different subjob checking the output.

Re: How to show stacktrace on error when running from command-line?

Of course you can.
The tSystem component provides to catch both output streams of a process to get it as global variabale.
You can access the content as string while the job is running and after the job finished. It is necessary to setup the options Standard Output and error Output to: "to global variable"
Here an example (in case your component in the job is the first of tSystem components):
((String) globalMap.get("tSystem_1_OUTPUT")) returns the normal output
((String) globalMap.get("tSystem_1_ERROROUTPUT")) returns the error output content.
You can use the tParallel component to run your job and in parallel to it a different subjob checking the output.

Thank you very much for your reply.
I have a few doubts, hope u can help me:
I can't find the tParallel component (its available on the community edition?)
What do i need to put on the command field of tSystem (if anything)?
So far i have something like this
tLogCatcher->tSendMail (where it sends me an email with the job's name and respective error.)
"All" i want is to get also the stack trace and place it on the message content.
I can't figure where to place the tSystem to be able to place ((String) globalMap.get("tSystem_1_ERROROUTPUT")) on the message field of tSendMail (it keeps giving me null when i receive the email)
Seventeen Stars

Re: How to show stacktrace on error when running from command-line?

Yes unfortunately the tParallel component is not part of the open source release. In this case you can only check the job output at its end.
Or you export the job as a standalone job and sends the outputs to a file (as Sabrina already suggested) and another job running parallel (checks the output file and sends the stack trace).
Why do you need the stack trace in a email? I would design the job and the tDie's in a way to have more meaningful messages. From my point of view this is a be far better approach than reading stacktraces to find the problem.

Re: How to show stacktrace on error when running from command-line?

Yes unfortunately the tParallel component is not part of the open source release. In this case you can only check the job output at its end.
Or you export the job as a standalone job and sends the outputs to a file (as Sabrina already suggested) and another job running parallel (checks the output file and sends the stack trace).
Why do you need the stack trace in a email? I would design the job and the tDie's in a way to have more meaningful messages. From my point of view this is a be far better approach than reading stacktraces to find the problem.

As far as the stack trace on email its because the job is supposed to be running everyday on an external server, so if anything goes wrong, i wanted to have all the possible information about what happened.
At least this was the ideia Smiley Happy
Seventeen Stars

Re: How to show stacktrace on error when running from command-line?

Yes I can imagine, it would be great but with the build-in possibilities, there is no way.
You could also consider to use the OnComponentError triggers to have tDie's closer to the problem instead of OnSubjobError.
When you are running the jobs in an external Job scheduler like JobScheduler from SOS Berlin you could configure the scheduler to get the whole output (log file) as email attachment.

Re: How to show stacktrace on error when running from command-line?

I have the same console output problem, but am not dependent on any enterprise components.
The problem is simple.  I built the job in Open Studio (Right-Click on Job -> Build Job).  I run the job on the command line and it runs perfectly, but there is not output.  I want the output that displays in the studio:
Starting job <JOB> at 15:38 17/02/2015.
connecting to socket on port 3927
connected
disconnected
Job <JOB> ended at 15:38 17/02/2015.
to display on the standard output (console).  I can redirect it there to where I need (via the > out.txt as you described above).
Is there a command-line parameter?  (ie.  MyJob.sh -consoleOutput) or something like that (tried that BTW, it's a CommandLine arg, but it doesn't work on the standalone job).
One Star

Re: How to show stacktrace on error when running from command-line?

1. Use the tAssertCather component to get the exception object.

2. Create a Routine class to handle the exception to a string

public static String getStacktrace(Object o)
   {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ((Throwable) o).printStackTrace(pw);
    return sw.toString(); // stack trace as a string     
   }
Moderator

Re: How to show stacktrace on error when running from command-line?

Hi dseiler,
Could you please indicate what's the error you are getting?
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.
Four Stars

Re: How to show stacktrace on error when running from command-line?

How to use stack trace to find out which column is responsible for null pointer excepction