Six Stars

Not Able to iterate through keySet of HashMap

Hi all,

 

The following is the error logs:

Exception in component tJavaFlex_7
java.lang.NullPointerException
at gap_bond_mapping.manage_issue_bond_cda_0_1.Manage_Issue_Bond_CDA.tJavaFlex_4Process(Manage_Issue_Bond_CDA.java:1339)

 

This is the line 1339 which cause the error: (This is in the 2nd tJavaFlex component)

 for (String c9 : (Set<String>)((Map<String,Map<Long,Long>>)globalMap.get("lMap")).keySet()){

 

where lMap in my case is described below: (This is in the first tJavaFlex component followed by 2nd tJavaFlex component)

Map <String, Map<Long,Long>> result = new HashMap<String, Map<Long,Long>>();

globalMap.put("lMap",result);

 

Anyone can help? Thanks a lot!

 

Regards,

FFUL

 

 

 

 

  • Big Data
  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Ten Stars

Re: Not Able to iterate through keySet of HashMap

I looked over the screenshots you sent, and I can see what you're trying to do. The only thing I'm uncertain of is the order that everything executes.  Because your javaflex components are connected with flow connections, and because there's some parallelism between components, it's possible that the second component is trying to get() something from globalMap before the first component has put() it there.

 

You may want to test that you're getting a non-null value when you retrieve "lmap".

4 REPLIES
Ten Stars

Re: Not Able to iterate through keySet of HashMap

That's strange.  I reconstructed the HashMap in one component and put it to the globalMap, then reference it in a second component in the same manner you did.  Everything seems to work fine, even if the Map is empty.

 

This was a job that's been working in the past?  Can you reproduce the error in the Studio?  I'm wondering if the error is actually being caused by that line of code.  

Six Stars

Re: Not Able to iterate through keySet of HashMap

Thanks for reply, I replicate same scenario in Eclipse, all's working well.. I'm not sure what's the real reason to cause the error..

Ten Stars

Re: Not Able to iterate through keySet of HashMap

I looked over the screenshots you sent, and I can see what you're trying to do. The only thing I'm uncertain of is the order that everything executes.  Because your javaflex components are connected with flow connections, and because there's some parallelism between components, it's possible that the second component is trying to get() something from globalMap before the first component has put() it there.

 

You may want to test that you're getting a non-null value when you retrieve "lmap".

Six Stars

Re: Not Able to iterate through keySet of HashMap

I moved the 2nd tJavaFlex to a subjob and then it worked!!! Appreciate your help!