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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tXMLMAP: expressions and java.lang.NullPointerException

Hello,
I have the following expression in tXMLMAP component.
Although I check every variable before to use it in the calcul, I have a java.lang.NullPointerException 
What is wrong with my expression?
Thanks in advance.
!= null && != null && != null && !=null && .equals("POD")? 
(Float.valueOf()+Float.valueOf()-Float.valueOf() )/1000 :
!= null && != null && !=null && .equals("JSF")? 
(Float.valueOf()+Float.valueOf())/1000 : null 
0683p000009MDgV.png
Labels (4)
18 Replies
Anonymous
Not applicable
Author

This part works alone:
!= null && != null && != null && !=null && .equals("POD")? 
(Float.valueOf()+Float.valueOf()-Float.valueOf() )/1000 : null
And this works alone:
!= null && != null && !=null && .equals("JSF")? 
(Float.valueOf()+Float.valueOf())/1000 : null 
But together it doesn't work.
I want to do something like:
if condition1 then A1
elseif condition 2 A2
else A3
Anonymous
Not applicable
Author

Can you send the XML that is causing it to fail? 
Anonymous
Not applicable
Author

Hello,
Attatched you find the  XML that is causing it to fail.
test.txt_20150518-1055.txt
Anonymous
Not applicable
Author

There don't seem to be any problems with that. It is kind of hard to debug an issue like this without running the job and then inspecting the code. Have you looked at the line of generated code this falls over on? In the error message it says line 2965. What does that line do? When you say it works when you separate the code into two, how do you use the result? Are both null?
Anonymous
Not applicable
Author

Hi,
Actually the problem is at the line 2567, attached you find the part of the source code including that line.
when I seperate the code, I mean that I calculate the variable DDPT only for "POD" or "JSF", so for the other one it is null.
0683p000009MDga.png 0683p000009MDdc.png
Anonymous
Not applicable
Author

Hmm, have you made changes to your XML or to the Job? The error in your previous error message was elsewhere. I have a suggestion to help you track this. Go to your tXMLMap and set it up to allow rejects to be returned. See the image below...
0683p000009MDgf.pngIn the top left, click on the button that is circled and then untick the "Die on Error" tick box. This will provide a "Rejects" output from the tXMLMap. YOu can hook that up to a tLogRow.
Next, create another output from your tXMLMap and pass every data column that you are using from your XML to that output without changing them. 
Run the job and take a look at the data and the error messages. It should provide a bit more info on what is going wrong.
Anonymous
Not applicable
Author

I changed the order of my output variables that's way the error changed the place but it's the same error and concerns the same expression.
I can't find the circled button, see the attached print screen.
I attatched also the job so that you can import it and see what's wrong.
Thanks in advance.
0683p000009MDgk.png collecte_fronataux.zip.zip
Anonymous
Not applicable
Author

My mistake, I was talking about the tMap component. It's useful to remember though.....(and should be implemented in the tXMLMap component).
Don't change the order of your outputs, just create another output table and add every data column to it without ANY data manipulation. No formulas, no expressions, nothing. Just the untouched data. Run that and see what is produced. Something is returning null (or maybe an empty string) where you are not expecting it.
Anonymous
Not applicable
Author

I added a new output tLogRow with the columns used to calculate the variable DDPT.
We see that only for the second line of the file that we have values for all columns.
I deleted all lines except the second line, the job is OK.
But in the expression of DDPT I check every variable, if at least one of the variables used in the expression is null the variable DDPT must be null.
For me the null variables are not used in the expression, because if it's null => DDPT=null the rest of the expression with class methods is not executed.
What's wrong with my expression?
0683p000009MDgp.png 0683p000009MDbN.png