A Job using the tXMLMap component fails with a 'java.lang.NullPointerException:null' error

Talend Version All versions

Summary

 
Additional Versions  
Product Data Integration
Component tXMLMap
Problem Description

A Job designed with the tXMLMap component sometimes fails with the following error when handling an XML document:

java.lang.NullPointerException:null
Problem root cause In tXMLMap, one of the conditions specified in the output filter or mapping is based on an XPath element, and calls a string function on the associated object:
(StringHandling.TRIM([row1.message:/tns:theProduct/tns:theCode])).equals("xyz")

This assumes the XPath /tns:theProduct/tns:theCode element exists in the input or source document. If it does not exist, ([row1.message:/tns:theProduct/tns:theCode])) is a null object.

 

So, calling a method, .equals, from a null object leads to a NullPointerException.

Solution or Workaround Add a condition to test that ([row1.message:/tns:theProduct/tns:theCode])) is not null. You can use the existing routine Relational.ISNULL:
!Relational.ISNULL([row1.message:/tns:theProduct/tns:theCode])) &&
(StringHandling.TRIM([row1.message:/tns:theProduct/tns:theCode])).equals("xyz")
Notice the symbol ! for the Boolean not logic.
JIRA ticket number  
Version history
Revision #:
4 of 4
Last update:
‎08-06-2018 01:23 PM
Updated by:
 
Labels (2)