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: 
Anonymous
Not applicable

[resolved] Null pointer exception - tMap

Hi everyone,
I am facing this error (c.f screenshot) for a while now. Usually Google is my friend, but not today.
Thank you for your advice,
0683p000009MCGM.png 0683p000009MCGR.png 0683p000009MCBE.png
EDIT :
I think the error comes from the absence of a null test. Therefore I tried this 3 kind of test but none works.

(String)row7.selling_price.equals(null))?0:row7.selling_price

(row7.selling_price.toString().equals(null))?0:row7.selling_price

(row7.selling_price == null)?0:row7.selling_price
Labels (2)
26 Replies
Anonymous
Not applicable
Author

Hi rhall_2.0,
I tried your solution before and as you can see on the screenshot below, it doesn't work neither 😕
Thx anyway.
0683p000009MC9S.png
Anonymous
Not applicable
Author

Just to summarize, please find below all the codes I already tried and that lead either to an ERROR or either to the wrong VALUE
WRONG VALUE Relational.ISNULL(row8.payment_date)?false:true
WRONG VALUE row8.payment_date==null?false:true
WRONG VALUE row8.payment_date.equals(null)?false:true
ERROR row8.payment_date.isEmpty()?false:true
ERROR row8.payment_date==""?false:true
WRONG VALUE String.valueOf(row8.payment_date)==null?false:true
WRONG VALUE String.valueOf(row8.payment_date).equals(null)?false:true
WRONG VALUE String.valueOf(row8.payment_date).isEmpty()?false:true
WRONG VALUE String.valueOf(row8.payment_date)==""?false:true
WRONG VALUE row8.payment_date.toString()==null?false:true
WRONG VALUE row8.payment_date.toString().equals(null)?false:true
WRONG VALUE row8.payment_date.toString().isEmpty()?false:true
ERROR row8.payment_date.toString()=""?false:true
ERROR (String)row8.payment_date==null?false:true
ERROR (String)row8.payment_date.equals(null)?false:true
ERROR (String)row8.payment_date.isEmpty()?false:true
ERROR (String)row8.payment_date==""?false:true
Thank you for your advice,
Anonymous
Not applicable
Author

Hi,
Have you already tried like this?
(row8.payment_date.equals(""))?false:true 
Regards, May T.
Anonymous
Not applicable
Author

Hi May T,
Thank you for this solution I didn't think about, but still it's not working (screenshot below)

0683p000009MCGb.png
Anonymous
Not applicable
Author

Hi,
Don't test with "Test" button of Expression Builder.
Can you please test by running the whole Job (with that code).
Regards, May T.
Anonymous
Not applicable
Author

I finally find something working, but it's dirty 0683p000009MACn.png
I don't get the null pointer exception error anymore.
((String.valueOf(row8.payment_date).equals("null"))
||
(String.valueOf(row8.payment_date).equals("NULL"))
||
(String.valueOf(row8.payment_date).isEmpty()))
?false
:true 


Thanks to all of you,
Anonymous
Not applicable
Author

May T, I tried to run the job with your code, but I got the null pointer exception again.
Since I am facing so many troubles, do you think I forgot to configure something in Talend?
Thx.
0683p000009MCGS.png
Anonymous
Not applicable
Author

Hi,
I think it's not related with configuration.
I'm not sure but I think it's depend on Type(data type) of your components and data file.
Regards, May.
Anonymous
Not applicable
Author


In MySQL, the field is recorded as DATE (with no parameters) and the values look like 'YYYY-MM-DD'
In Talend, inside the tMap, the field is identified as Date "dd-MM-yyyy"
=> So, I change the format in the tMap to "yyyy-MM-dd", but it doesn't change anything. I still got the error with the code below.

(row8.payment_date.equals(""))?false:true 

Anyway, thank you for your help, it seems that I got no choice to keep my dirty solution 0683p000009MACn.png
Anonymous
Not applicable
Author

Is "payment_date" a Date or a String? I assumed it was a Date since I didn't see anywhere where it said otherwise. If it is a String, then it is entirely possible that null is being represented as a String of "null". This is an annoying "feature" of Talend with the help of Java. If you have a null String and you concatenate it with a populated String, the null will be converted to "null".
Demonstrated in the example below.....
String hello = "hello";
String nullValue = null;
String result = hello+nullValue;
System.out.println(result);
If you run that code you will get ....
"hellonull"
You need to be aware of this when working with Strings that may have gone through a similar process.