Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

 

 

 

 

Labels (4)
1 Solution

Accepted Solutions
cterenzi
Specialist
Specialist

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".

View solution in original post

4 Replies
cterenzi
Specialist
Specialist

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.  

Anonymous
Not applicable
Author

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..

cterenzi
Specialist
Specialist

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".

Anonymous
Not applicable
Author

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