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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
shalinim1
Contributor III
Contributor III

NullPointerException

Hi,

I have used tjavaflex to get source and target count values. There is two flow to target table insert and update.

I wrote the code to get the sum of two flows:

row4.targetcount=Integer.sum((Integer)globalMap.get("tDBOutput_1_NB_LINE"),(Integer)globalMap.get("tDBOutput_2_NB_LINE"));

when I run the job, it is throwing the following exception,

Exception in component tJavaFlex_1 (demo)

java.lang.NullPointerException

 at case_study_etl_process.demo_0_1.demo.tStatCatcher_1Process(demo.java:5756)

 at case_study_etl_process.demo_0_1.demo.tPrejob_1Process(demo.java:4668)

 at case_study_etl_process.demo_0_1.demo.runJobInTOS(demo.java:6118)

 at case_study_etl_process.demo_0_1.demo.main(demo.java:5916)

Exception in component tJavaFlex_1 (demo)

java.lang.NullPointerException

 at case_study_etl_process.demo_0_1.demo.tStatCatcher_1Process(demo.java:5756)

 at case_study_etl_process.demo_0_1.demo.runJobInTOS(demo.java:6130)

 at case_study_etl_process.demo_0_1.demo.main(demo.java:5916)

Exception in component tJavaFlex_1 (demo)

java.lang.NullPointerException

 at case_study_etl_process.demo_0_1.demo.tStatCatcher_1Process(demo.java:5756)

 at case_study_etl_process.demo_0_1.demo.runJobInTOS(demo.java:6164)

 at case_study_etl_process.demo_0_1.demo.main(demo.java:5916)

Labels (2)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

@Shalini M​ , as per error you are getting null values for (Integer)globalMap.get("tDBOutput_1_NB_LINE") or (Integer)globalMap.get("tDBOutput_2_NB_LINE")

 

you need to handle null values.can you try to write below way and see.

 

row4.targetcount=Integer.sum(((Integer)globalMap.get("tDBOutput_1_NB_LINE")==null?0:(Integer)globalMap.get("tDBOutput_1_NB_LINE")),(Integer)globalMap.get("tDBOutput_2_NB_LINE")==null?0:(Integer)globalMap.get("tDBOutput_2_NB_LINE")));

 

Thanks,

Manohar

View solution in original post

3 Replies
manodwhb
Champion II
Champion II

@Shalini M​ , as per error you are getting null values for (Integer)globalMap.get("tDBOutput_1_NB_LINE") or (Integer)globalMap.get("tDBOutput_2_NB_LINE")

 

you need to handle null values.can you try to write below way and see.

 

row4.targetcount=Integer.sum(((Integer)globalMap.get("tDBOutput_1_NB_LINE")==null?0:(Integer)globalMap.get("tDBOutput_1_NB_LINE")),(Integer)globalMap.get("tDBOutput_2_NB_LINE")==null?0:(Integer)globalMap.get("tDBOutput_2_NB_LINE")));

 

Thanks,

Manohar

shalinim1
Contributor III
Contributor III
Author

Thank you @Manohar B​ It worked! 😊

manodwhb
Champion II
Champion II

@Shalini M​ ,glad to help you