Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
BeginnerNeedsHelpPlease

child job - simple context parameter wiht filepath does not work : another filepath is assigned

hello

I have a simple parent job whith one child job which has to read an excel file A and create another excel file B.

In the child job I use a context parameter (named fichier) which will store the filepath for the file B.

I use tjava component to assign the filepath to the context parameter :

context.fichier = "C:/talend/workspace/ESSAI_CONTEXTE/examples_files/temp.csv";

then in the outputfile, i use this context parameter

see my atteched pics

When I tun the parent job, I have an error with the output file.

it looks like the context parameter is assigned to another filepath : C:\Program Files (x86)

i never assigned C:\Program Files (x86) to my context parameter...

this is the error (translated from french)

Exception in component tFileOutputDelimited_1 (child1)

java.io.FileNotFoundException: C:\Program Files (x86)\Talend-Studio\studio (Access refused)

can you help me?

Labels (2)
3 Replies
anselmopeixoto
Partner - Creator III
Partner - Creator III

Hello @adi nul​ 

 

I assume you are setting the context.fichier variable on the tJava_2 component shown in your image.

 

If it is the case, that's the reason you're getting the java.io.FileNotFoundException, because the tJava_2 component is in the middle of the subjob flow.

 

When a subjob is executed, it actually starts from the output component, so the file path is set before the data flow is started. You can observe this by the statistics above each row. It is pretty fast, but when you start the job you will notice the word "Starting" appearing first over the row connected to the output component. It's easier no observe using a tDBOutput component, as it takes a little bit longer to connect to a database than it takes to create an empty file.

 

If you need to dinamically set the file path, you can use a tJava component before the subjob that writes into that file. And if the file path is set based based on the input data, you can create an iteration for this purpose.

BeginnerNeedsHelpPlease
Author

yes I set the context.fichier in Tjava_2 component.

So Tjava_2 component has to be in the parent job and then I call the child job : that's correct?

thank you

anselmopeixoto
Partner - Creator III
Partner - Creator III

It depends on what is the source of the content you want to set in the context variable.

 

If the output file path is known during the execution of the parent job, you could simply pass the context variable to the child job using tRunJob component options "transmit whole context" or "context param".

 

But if the content you will set to the context variable depends on the execution of the child job, you could just put the tJava component outside of the data flow and connect the subjobs using onComponentOk or onSubJobOk triggers.

 

For example:

 

tJava_2 -> onComponentOk / onSubjobOk -> tFileInputExcel -> row1 -> tMap -> out -> tFileOutputDelimited