Six Stars

globalMap.get() is not working

I am using a global map variable in a tJavaRow component. but its giving an error message.

"cannot make a static reference to the non-static field".

I am using BigData Spark job.

How Do i overcome this issue.

 

globalmapError.jpg

  • Big Data
  • Data Integration
6 REPLIES
Ten Stars

Re: globalMap.get() is not working

Can you show your component code instead of the Code tab?
Six Stars

Re: globalMap.get() is not working

I have created a simple mapping to show this error.

 

errorglobalmap.png

 

 

the error is coming from the tJavaRow component which i have shown in the first post.

 

here is the code of the tjavarow component .

 

 String[] values = (String[])globalMap.get("values");
 
 row1.a = row2.a;
 row1.b = row2.b;

here is the code in tjava component

String[] values = { "This", "is", "test" };

globalMap.put("values", values);

 

try reproducing the error in you system.

 

request to help me on this..

 

 

Six Stars

Re: globalMap.get() is not working

@Tom4sz, I tried the way you explained. For me it is working fine, i was able to get the values from globalMap in the tJavaRow.

I've exported my job (Test.zip), you can download it and have a look.

 

Hope this helps.

- JG
Six Stars

Re: globalMap.get() is not working

Hi,

I am not able to open your job in talend.

 

what kind of job is that.. is it standard or bigdata job?.

 

I am specifically talking about Bigdata Spark job.

 

In Talend standard job , I am able to get the output . but the same code in talend big data is giving error.

 

I am using 'Talend big data plaform 6.2'

 

Thanks

Six Stars

Re: globalMap.get() is not working

Sorry it was a standard job, not a Bigdata Spark job. I will give it a try with Bigdata Spark job.

- JG
Six Stars

Re: globalMap.get() is not working

I am trying with an alternative

 

I have created a context variable of type Object.

 

srccols.jpg

To this variable I am saving my string array  in tJava component

String[] cols = { "This","is","test" };
context.SrcCols = cols;

I am accessing this context variable in tJavarow

String[] Cols = (String[])context.SrcCols;

but while running its giving the following error.

java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;