Context Load from text file - Can't read the loaded variables

Six Stars

Context Load from text file - Can't read the loaded variables

So I created this quick job and strangely, even after getting confirmation that the variables have been loaded, I can't seem to read the variables using context.<var_name>. What am I doing wrong?

 

The input file has just one variable 'temp_var' with value set to 'passed' (temp_var=passed). While loading the job, I also see the info in the talend log window (tContextLoad_2 set key "test_var" with value "passed"). Further, I can use the context.containsKey("test_var") construct and it yields 'true' in the Java Node. But the moment I try to run the following command, it fails:

 

System.out.println("Value of var test_var read from context " + context.test_var);

 

Kindly help.

 

Screenshot from 2018-08-10 16-49-20.png


Accepted Solutions
Six Stars

Re: Context Load from text file - Can't read the loaded variables

So I saw the source code of another job with context variables and found that talend internally manages the context variables using the getProperty method. Used that information and it all worked fine.

System.out.println("Value of var test_var read from context " + (String) context.getProperty("test_var"));

All Replies
Six Stars

Re: Context Load from text file - Can't read the loaded variables

So I saw the source code of another job with context variables and found that talend internally manages the context variables using the getProperty method. Used that information and it all worked fine.

System.out.println("Value of var test_var read from context " + (String) context.getProperty("test_var"));