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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
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)
26 Replies
janhess
Creator II
Creator II

The NullPointer Exception comes from trying to do a function on a collateral field when there hasn't been a match. Check for null in the rule.
Jj5
Contributor III
Contributor III
Author

The NullPointer Exception comes from trying to do a function on a collateral field when there hasn't been a match. Check for null in the rule.

Where would I put the rule? I tried putting the code:
Collateral.FIELDNAME != null && Collateral.FIELDNAME.length() > 0 ? Collateral.FIELDNAME : null
on every field in the output where I mapped the collateral file to the output file and it didn't help.
janhess
Creator II
Creator II

For example in rule for escrow put
! Relational.ISNULL(
before existing rule and ) at end.
But if you use an inner join for input none of the fields will be null unless there's nulls in the data.
Jj5
Contributor III
Contributor III
Author

For example in rule for escrow put
! Relational.ISNULL(
before existing rule and ) at end.
But if you use an inner join for input none of the fields will be null unless there's nulls in the data.

When I tried that it gave me an error saying that it can't convert Boolean to String. I literally put the ! Relational.ISNULL() around my field, ie ! Relational.ISNULL(Collateral.ESCROW). I assume I'm supposed to use it as an if test expression, like:
! Relational.ISNULL(Collateral.ESCROW) ? Collateral.ESCROW : null
Is that correct?
janhess
Creator II
Creator II

Yes sorry. should be
! Relational.ISNULL(value)?rule true:rule false
It's difficult to see what's in your rules from the picture.
Jj5
Contributor III
Contributor III
Author

Yes sorry. should be
! Relational.ISNULL(value)?rule true:rule false
It's difficult to see what's in your rules from the picture.

I went ahead and added code to every Collateral field so it looks something like this:
! Relational.ISNULL(Collateral.PrimaryBorrowerName != null && Collateral.PrimaryBorrowerName.length() > 0 ? Collateral.PrimaryBorrowerName : null) ? Collateral.PrimaryBorrowerName != null && Collateral.PrimaryBorrowerName.length() > 0 ? Collateral.PrimaryBorrowerName : null :null
It compiles fine, but still gives me a nullpointerexception on line 1
Edit: I know the code is redundant with the null testing, but I just wanted to try it out as fast as possible.
janhess
Creator II
Creator II

Firstly the rule is wrong. All you need is
! Relational.ISNULL(Collateral.PrimaryBorrowerName)?Collateral.PrimaryBorrowerName?null.
but this isn't where the problem is as there's no function done on the data.
Look on your code tab for the line being flagged as the null pointer exception and it will tell you where the problem is.
Jj5
Contributor III
Contributor III
Author

Firstly the rule is wrong. All you need is
! Relational.ISNULL(Collateral.PrimaryBorrowerName)?Collateral.PrimaryBorrowerName?null.
but this isn't where the problem is as there's no function done on the data.
Look on your code tab for the line being flagged as the null pointer exception and it will tell you where the problem is.

I looked at the error and it pointed me to the MAILADDR2 field. Just to confirm your theory I deleted the Collateral input fields on every output where there was a function and it compiled and ran without errors so you're 100% correct, thank you so much. I've been trying to figure this out for a week and it was driving me crazy, but I was looking in the wrong place the whole time.
For the MAILADDR2 field, I originally tried to remove null values so the code is a mess. Currently it is written as:
Loan.MailAddr2 != null && Loan.MailAddr2.length() > 0 && Loan.MailState != null && Loan.MailState.length() > 0 && Loan.MailZip != null && Loan.MailZip.length() > 0 ? Loan.MailAddr2.replace("\"","").isEmpty() ? Loan.MailCity.replace("\"","") + " " + Loan.MailState.replace("\"","") + " " + Loan.MailZip.replace("\"","") : Loan.MailAddr2 : null
I'm assuming that the correct code would be:
!Relational.ISNULL(Loan.MailAddr2.replace("\"","").isEmpty() ? Loan.MailCity.replace("\"","") + " " + Loan.MailState.replace("\"","") + " " + Loan.MailZip.replace("\"",""))
? Loan.MailAddr2.replace("\"","").isEmpty() ? Loan.MailCity.replace("\"","") + " " + Loan.MailState.replace("\"","") + " " + Loan.MailZip.replace("\"","")
: null
janhess
Creator II
Creator II

You probably don't need the isEmpty check.
Jj5
Contributor III
Contributor III
Author

You probably don't need the isEmpty check.

I'm guessing that when I started this project I saw a nullpointerexception and assumed it was because a field was empty so I put a lot of unnecessary code in. Thanks a lot for the help. I'll try adding the Relational.ISNULL() code in soon and report back on whether or not it works.