[resolved] Question about implicit context load.

One Star

[resolved] Question about implicit context load.

Hi,
I checked the documentation as well as the forum and have not found what I am looking for so I will try my luck here.
I am trying to load values from a .txt file into a job using a project's implicit context load feature and am encountering errors when the job runs due to the job not
being able to resolve the variable set-up in the. I am thinking I did not set-up something up correctly and am not sure what. Below are some details.
-> the .txt file's values are as follows... host;devserver host is the context variable, ; is the field seperator, and devserver is the host name. I have the ; value
defined as the field seperator in the 'implicit context load' tab of the Project Settings section.
-> the value $_context{host} is used for the Host value on a tMysqlConnection component. For beginners, I am not sure if that is the correct way to reference an
implicit context field. When I run the job, a compilation error gets thrown due to the job not being able to resolve the context variable ('host' in my case).
-> Curious enough is that the implicit context value is getting parsed when the job runs. I can tell this due to the following message getting displayed in the console
when the job runs. Implicit_Context_Context set key "host" with value "devserver". The following message also gets displayed on the console when the job is
run. Warning: Parameter "host" is a new parameter of Implicit_Context_Context
-> If this helps, below are some errors that get thrown when the job runs - I think this is due to the way I have the context variable set up (as mentioned above).
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token(s), misplaced construct(s)
Syntax error on token(s), misplaced construct(s)
The operator + is undefined for the argument type(s) String
-> Below is a snippet of the code that contains the unresolved variable.
String url_tMysqlConnection_1 = "jdbc:mysql://" + $_context{host} + ":" + "3310" + "/" + "datawarehouse" + "?" + proprtties_tMysqlConnection_1;

Any advice will be greatly appreciated.
Tom

Accepted Solutions
One Star

Re: [resolved] Question about implicit context load.

Hi Shong,
I am all set on this. I neglected to add the implicit context variables as context variables to my job. Once that was done, everything worked as wanted.
Thank you for your help on this.
Tom

All Replies
Community Manager

Re: [resolved] Question about implicit context load.

Hi Tom
If host is the variable name, you can use the context variable like this:
context.host
Good luck!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Question about implicit context load.

Hi Shong,
Thank you for your response. As with my initial message on this issue, please bear with me.
For an implicit context variable that gets loaded from a file (.txt in this case), is there something in particular that needs to be done to make it visible to a job? The reason
I ask is that the variable (host in this case) is not visible as a context variable to the job. I did the control, space key combination after 'context.' and the implicit variable
from the .txt file is not visible. I am thinking I am missing a step that makes the variable visible to the job.
I looked at the documentation (Talend Integration Suite 4.x) and it seems like the section that pertains to implicit context loads it is slightly out of date from the version of
the Talend Integration Suite that I am using which is version 4.1.2. In particular, is the reference to the 'Extra' tab for a job that allows for the use of implicit context load
variables.
More questions... Is the 'Extra' tab for a job in use in 4.1.2 and I am just not seeing it? If the Extra tab is not available in 4.1.2, how does a job make use of a variable
introduced to a project via the implicit context load option?
Thank you in advance and have a great day.
Tom
One Star

Re: [resolved] Question about implicit context load.

Hi Shong,
I am all set on this. I neglected to add the implicit context variables as context variables to my job. Once that was done, everything worked as wanted.
Thank you for your help on this.
Tom
Community Manager

Re: [resolved] Question about implicit context load.

Hi Shong,
I am all set on this. I neglected to add the implicit context variables as context variables to my job. Once that was done, everything worked as wanted.
Thank you for your help on this.
Tom

Hi
Good news, thanks for your feedback!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Question about implicit context load.

Hi Tom,
I need to implement the same one as your's.Could you please provide some details of implicit context load like configuration for implicit context load.If you could provide some reference to this alos fine.
Thanks,
Raakesh R
Seven Stars

Re: [resolved] Question about implicit context load.

Try the user guide or help.talend.com.
One Star

Re: [resolved] Question about implicit context load.

Hi Shong,
I am all set on this.  I neglected to add the implicit context variables as context variables to my job.  Once that was done, everything worked as wanted.  
Thank you for your help on this.
Tom

Hi,
I am also getting the same issue but unable to see option to "select or neglect to add the implicit context variables as context variables to my job".
Can you please help me to find out this option?
Thank you in anticipation.
Regards,
Manish
One Star

Re: [resolved] Question about implicit context load.

Hi Shong,
I am all set on this.  I neglected to add the implicit context variables as context variables to my job.  Once that was done, everything worked as wanted.  
Thank you for your help on this.
Tom

Hi,
I am also getting the same issue but unable to see option to "select or neglect to add the implicit context variables as context variables to my job".
Can you please help me to find out this option?
Thank you in anticipation.
Regards,
Manish
I got it. Seems I wasn't calling it correctly.
I used following and it worked:
     context.get("value1")