Client cannot be resolved to a variable

One Star

Client cannot be resolved to a variable

TOS 5.0.2/Win 7
In the tutorial "Working with global context variables", (Exercise16), I get a compilation error "Client cannot be resolved to a variable", when trying to run the tutorial. What am I missing?
Community Manager

Re: Client cannot be resolved to a variable

Hi
It is a compilation error in the job generated code, it indicates the variable 'Client' is not declared before you use it.
Can you please capture a screenshot of the editor of tRowGenerator?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Client cannot be resolved to a variable

Hi Shong, here is the screenshot of the tRowGenerator editor. I've checked the CLASSPATH/JAVA_HOME/PATH environment variables, and they seem to be ok when I work with Java directly.
One Star cze
One Star

Re: Client cannot be resolved to a variable

I've got the same error, but I don't see the solution in the posts for this issue.....
One Star

Re: Client cannot be resolved to a variable

Thats because you haven't made any context variables in your job......
Please declare the context variable in the Context Tab and Use that variable in your row generator.
One Star

Re: Client cannot be resolved to a variable

Hi Nayan,
I?m totally new to talend and can you please explain a bit how to solve this issue?
One Star

Re: Client cannot be resolved to a variable

On the repository side of the talend screen you will see under JOB DESIGNS the tab CONTEXTS.
if you right click on Contexts you can add a new context group say Exercise16.
This starts a 'wizard' process where you are asked to name the context so you would enter Exercise16
clicking next brings you onto the data fields.
Click + to add a new fiels i.e. your variable it will appear at the top as new1 you can change the name to what you want and you will see the name change on the right side as well under the script code heading. The type is a drop down list and probablty you may want for the exercise to keep it the same as the default i.e. String.
Clinking finish saves this new context group and it should appear under the Context tab
Return to your job and if you look at the bottom section of the middele pane of the editor you will see several tabs like JOB Component Contexts Run , Problems. You will need to select the Contexts tab.
To add your new context to your job the easy way is to look at the bottom left set of buttons there should be 5
+, X, up arrow, down arrow , and a icon that is a square with three connected circles i.e. the last one on the right.
If you click this on you can see all your context groups and alongside each group there is a selection box that either is empty or has a green tick or green square. Empty means you have not selected the context , green tick means you select all of the contents of the context and green square is to show that you have selected some of the context variables. Note if you make a green tick ny selecting all button and subsequently go back and add a new variable to the context group you should find that your green tick now shows as a green square.
Following all of this shold now show your context variables as being available to exercise 16
One Star

Re: Client cannot be resolved to a variable

I am running into the same issue with this tutorial. It seems odd to me that a tutorial on how to use context variables would have a prerequisite of having to setup a context variable.
Can someone explain this a little more? The above explanation of how to create a context variable did not specify the name of the variable(s) to create? As this is all new a little more hand holding is necessary. Thanks for your time.
One Star

Re: Client cannot be resolved to a variable

In workbench select context tab and enter the name of the context and it's type.
One Star

Re: Client cannot be resolved to a variable

FIX for "Client cannot be resolved to a variable" issue:
There is a simple fix for this. When configuring the tRowGenerator, do exactly what the tutorial says to do to configure "company":
To set the company column, select String in the Type field, select ... in the Functions field, go to the Function parameters view at the bottom and type in "Client" in the Value column.
You have to make sure to use quotes around "Client" so it is used as a literal. The graphic in the tutorial fails to show this. However, I believe that this is the original intent since the whole idea of the first step in the tutorial is just to see if the output file is being written correctly. The rest of the tutorial then goes into setting up context variables to replace the literal values.
Cheers!
One Star

Re: Client cannot be resolved to a variable

Create a context variable (local or global). Go to the component Tab, select the field where you want context variable and press the Keys "Ctrl + Space". It will list the available variables. From that you can select the same.
Thank you