Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Jj5
Contributor III
Contributor III

[resolved] NullPointerException (possible bug) in tMap [Need Help With a Filter]

I discovered what the actual problem was and posted a screen shot. See my last post for details. I'd be happy to host a WebEx session if anyone is interested enough in that.





I have a job that combines 3 delimited input files into a single delimited output file. The program runs perfectly, no errors.
However I have to change one of my delimited input files (the main) to a different excel input file. I mapped it correctly, all the fields are nullable. When I run the job I get the following error:
Exception in component tMap_1
java.lang.NullPointerException
at testproject.pimco_0_2.PIMCO.tFileInputDelimited_2Process(PIMCO.java:24714)
at testproject.pimco_0_2.PIMCO.runJobInTOS(PIMCO.java:27633)
at testproject.pimco_0_2.PIMCO.main(PIMCO.java:27498)
I tried a new job where I have only the new excel file and I copied the tMap. When I run that job, it works fine. The nullpointer error only happens when I try to combine the new file with the two other delimited input lookup files.
I tried making different files the main file and the problem is always with the main, never the lookup files.
I forgot to mention that the excel file has no null values. I tried changing every cell to the same string value and I still got the same error. I also used Talend to convert the file from excel to a CSV so it would be the same filetype as the other two. Talend still gave me a null pointer error when I tried combining the three files, but when I only use the new file I get no error.
This is pretty urgent so any suggestions would be greatly appreciated.
Thanks a ton in advanced,
JJ Potgieter.
Labels (4)
1 Solution

Accepted Solutions
janhess
Creator II
Creator II

It's because you're doing the replace before checking for null (I think). So you need to do the isnull and then replace if false.

View solution in original post

26 Replies
Jj5
Contributor III
Contributor III
Author

Here is my screen. Let me know if you need a different screenshot.
willm1
Creator
Creator

You may have already tried this - and this may not be your issue at all - but in case it is, it's always good practice to handle nulls before using fields...
row1.account_type != null && row1.account_type.length() > 0 : row1.account_type.equals("Parent")
Jj5
Contributor III
Contributor III
Author

You may have already tried this - and this may not be your issue at all - but in case it is, it's always good practice to handle nulls before using fields...
row1.account_type != null && row1.account_type.length() > 0 : row1.account_type.equals("Parent")

I will do so in the future, but I have a lot of fields and I'm fairly confident that this isn't the problem. The reason why I'm sure that it isn't the problem is because I changed every cell in the excel file to the same string value to make sure that none of the cells are null, but I still got the error.
Anonymous
Not applicable

hi all,
are you using some filter in your Tmap or any java function like comparison or equality ?
null pointer is often the result for using a 'java function' that doesn't support null value.
As willm as mentionned, manage null value is a good way to avoid that.
Try to catch null value by using tschemaComplianceCheck and reject flow to catch those 'bad data'.
You also use the java debug run to find null value, but it's more a java expert solution.
hope it helps
regards
laurent
janhess
Creator II
Creator II

Something wrong with the first record in tFileInputDelimited2. Does it have a header which you didn't include?
Jj5
Contributor III
Contributor III
Author

Thanks for the suggestions kzone and janhess, but they're not the issue. The filter sounded really promising because I forgot that I had included one, but when I removed it nothing changed.
I did trouble shoot where the error is coming from. When the collateral lookup is linked to the new file's LoanNumber I get the error. It doesn't give me an error when the collateral lookup file is connected to the old Loan file, only the new Loan file. I'm not 100% sure what this means but at least I know where to look for my error.
I just confirmed that there are plenty of LoanNumbers that exist in both the collateral file and the Loan file, so I'm really lost as to what could be causing this error.
I went into tMap and deleted every field where I mapped the collateral fields to the output file, so only the Insurance and Loan data is there, and I still have the same error...
Jj5
Contributor III
Contributor III
Author

I seem to have found the cause of the problem, but I'm not sure how to fix it. When I use the Loan file's LoanNum as the expression key for the Collateral file, I get a null pointer error if one file has a LoanNum the other file doesn't have. I tried filtering it out on the output file and you can see my code in the screenshot. It seems like the filter code I used for the output only works a few times. It's currently getting the null exception error on line 681.
The reason for this error is that on line 682 there is a LoanNum in the Loan file that doesn't exist in the Collateral or Insurance file. The filter should exclude it though, shouldn't it?
I fixed the filter to Loan.LoanNum.equals(Collateral.LoanNum) as it should be, but it still gives me the null exception error on line 681
janhess
Creator II
Creator II

You shouldn't be using the filter in that way. That condition is handled by the join on the input. If you have an inner join it will not pass any unmatched Collateral records to the output.
Jj5
Contributor III
Contributor III
Author

You shouldn't be using the filter in that way. That condition is handled by the join on the input. If you have an inner join it will not pass any Collateral records to the output.

I see. Then how do I handle the nullpointerexception?