One Star

Unable to run job in different context by changing the .bat file

Hi
I've set up a simple Talend job to run in different contexts (say, context1 and context2).
When the job is run in TOS with context1, it runs correctly with the varibales defined in context1. Similarly, when I change the context from the drop-down to context2, it runs with the variables defined in context2.
However, when I export the job with a default context (say, context1), and tries to run it from the command-line, it always runs with the same context (context1) everytime
I've been trying to run the job in a different context by changing the context value in the ".bat" file but I'm unable to do so.
Even after I change context in the .bat file from "--context=context1" to "--context=context2", the job runs with the variables defined in context1.
Can you please suggest if I'm doing anything wrong?
I have followed the exact same steps as mentioned in the tutorial:
http://www.talendforge.org/tutorials/tutorial.php?language=english&idTuto=35
Thanks
Kshitij
11 REPLIES

Re: Unable to run job in different context by changing the .bat file

One thing to keep in mind is that Talend will create different context files for each context group you define in the job.
in your exported scripts you should find a directory:
/<job_name>/<job_name>/<project_name>/<job_name>/contexts/
This will contain the .properties files that define your context varibles-- verify that your wanted context.properties file exists and contains the varibles you expect.
When you refer to the context group by using the paramater "--context=<context_name>" use exactly the same name as your wanted context file minus the .properties extension.
Also, if your job contains multiple sub-jobs, they will get their own set of context files-- even if "transmit whole context" is checked in your tRunJob's
One Star

Re: Unable to run job in different context by changing the .bat file

Hi John
Thanks for the reply.. I have re-re-re-verified all these things and ran the job again and again... But it always runs with the same context with which it is exported.
And you know what, I even removed the following lines "--context=context1" from my batch file. Even then the job was executing with the context1 parameters.
I'm really stuck at this point and finding some other way to load contexts at job startup.
Regards
Kshitij

Re: Unable to run job in different context by changing the .bat file

can you create a simple test job, say a single tJava component that prints the values of a context variable and upload the items here?
What version of TOS are you working with?
This feature works as expected for me on linux in TIS 4.02, 4.03 and 4.1.1
One Star

Re: Unable to run job in different context by changing the .bat file

Hi,
I'm using Talend v4.1.1.r50363 on Windows XP
I followed the following steps:
img1.jpg:
I created a tJava component with following code:
System.out.println(context.mykey);
img2.jpg:
I defined 2 context groups:- context1 and context2 with different values to the key "mykey"
img3.jpg:
Ran the job in context2 through TOS v4.1.1.r50363. It ran successfully with context2 and printed value "context is 2"
img4.jpg:
I exported the job with context2 (as default selection) with all options checked including Context scripts.
img5.jpg:
It created 2 context files (.properties) for both the contexts inside /<job_name>/<job_name>/<project_name>/<job_name>/contexts/
img6.jpg:
See the contents of the 2 context files and the batch file (see --context=context2)
img7.jpg:
I ran the batch file from command prompt (Windows) without altering the batch file (i.e. with context2). It printed "context is 2"
(see yellow boundary)
Then I changed the batch file to "--context=context1" and again ran it through command prompt. It again printed "context is 2".
(see blue boundary)
Seventeen Stars

Re: Unable to run job in different context by changing the .bat file

hi all
upgrade to TOS-Win32-V4.1.2 if it's possible.
there'is known problem about using "context=...." into command line .bat
regards
laurent
@JohnGarrettMartin : work fine for you on 4.1.1 ??
One Star

Re: Unable to run job in different context by changing the .bat file

Hi kzone,
Thanks for the information. I'll try to see if I can upgrade to Talend v4.1.2
However, if I continue to use v4.1.1, then is there any other alternative to set the context variables in the job beginnnig ?
Regards
Kshitij
One Star

Re: Unable to run job in different context by changing the .bat file

Hi,
I have installed Talend v.4.1.2 also and created the same job with it.
But surprisingly, this isn't working too!!
The job always runs with the default context with which it is exported
Has anyone found a workaround yet?
- Kshitij
Seventeen Stars

Re: Unable to run job in different context by changing the .bat file

oups
Seems that the bugs remain ....
regards
laurent
Seventeen Stars

Re: Unable to run job in different context by changing the .bat file

Re: Unable to run job in different context by changing the .bat file

I double checked with 4.1.1 and can confirm that it exists. Sorry for any confusion, My previous post saying it worked was in error.
this will be a blocking issue for my teams Smiley Sad
Thanks for pinpointing it Kzone!
Seventeen Stars

Re: Unable to run job in different context by changing the .bat file

hi
issue in 4.1.3
have a look at branch Smiley Wink
regards
laurent