{Resolved} Help Diagnosing Null Pointer

Five Stars

{Resolved} Help Diagnosing Null Pointer

I'm having a null pointer exception when I test my job but according to the stack trace the problematic line of code is a simple assignment. The only way I'm aware of that this code could cause a null pointer exception is if WEXFuelTransform_tmp.DriverID doesn't exist on the class...any ideas? In my tMap I have meticulously checked that every field is not null before calling a function on it.

Capture.PNG

 Here is my tMap variable scope:

 

{ // start of Var scope
	// ###############################
	// # Vars tables

	Var__tMap_1__Struct Var = Var__tMap_1;// ###############################
	// ###############################
	// # Output tables

	WEXFuelTransform = null;
	// # Output table : 'WEXFuelTransform'
	WEXFuelTransform_tmp.FuelTransactionID = 0;
	WEXFuelTransform_tmp.CardNumber = row1.CardNumber;
	WEXFuelTransform_tmp.CustomerVehicleID = row1.CustomerVehicleID;
	WEXFuelTransform_tmp.PostDate = row1.PostDate;
	WEXFuelTransform_tmp.TransactionTimestamp = row1.TransactionDate != null
		&& row1.TransactionTime != null ? TalendDate
			.parseDate(
					"MM/dd/yyyy HH:mm:ss a",
					row1.TransactionDate
					+ " "
					+ row1.TransactionTime)
			: null;
	WEXFuelTransform_tmp.Merchant = row1.Merchant;
	WEXFuelTransform_tmp.MerchantName = row1.MerchantName;
	WEXFuelTransform_tmp.MerchantAddress = row1.MerchantAddress;
	WEXFuelTransform_tmp.MerchantCity = row1.MerchantCity;
	WEXFuelTransform_tmp.MerchantState = row1.MerchantState;
	WEXFuelTransform_tmp.MerchantZipCode = row1.MerchantZipCode;
	WEXFuelTransform_tmp.DriverName = row1.DriverName;
	WEXFuelTransform_tmp.DriverID = row1.DriverID;
	WEXFuelTransform_tmp.CurrentOdometer = row1.CurrentOdometer;
	WEXFuelTransform_tmp.AdjustedOdometer = row1.AdjustedOdometer != null ? row1.AdjustedOdometer
			: row1.CurrentOdometer;
	WEXFuelTransform_tmp.Product = row1.Product;
	WEXFuelTransform_tmp.Units = row1.Units;
	WEXFuelTransform_tmp.UnitCost = DataParsing
		.parseAccountingValue(row1.UnitCost);
	WEXFuelTransform_tmp.FuelCost = DataParsing
			.parseAccountingValue(row1.FuelCost);
	WEXFuelTransform_tmp.NonFuelCost = DataParsing
			.parseAccountingValue(row1.NonFuelCost);
	WEXFuelTransform_tmp.GrossCost = DataParsing
			.parseAccountingValue(row1.GrossCost);
	WEXFuelTransform_tmp.ExemptTax = DataParsing
			.parseAccountingValue(row1.ExemptTax);
	WEXFuelTransform_tmp.TransactionFee = DataParsing
			.parseAccountingValue(row1.TransactionFee);
	WEXFuelTransform_tmp.NetCost = DataParsing
			.parseAccountingValue(row1.NetCost);
	WEXFuelTransform_tmp.ReportedTax = DataParsing
			.parseAccountingValue(row1.ReportedTax);
	WEXFuelTransform_tmp.MPG = row1.MPG != null ? Float
			.parseFloat(StringHandling.EREPLACE(row1.MPG, ",", ""))
			: null;
	WEXFuelTransform_tmp.CPM = DataParsing
			.parseAccountingValue(row1.CPM);
	WEXFuelTransform = WEXFuelTransform_tmp;
	// ###############################

} // end of Var scope

And here is the parseAccountingValue function:

/**
* parseAccountingValue: Takes in a dollar amount in accounting notation such as "$3.24" or "($0.60)" and returns a positive or negative decimal
*
*
* {talendTypes} String
*
* {Category} Data Parsing
*
* {param} string("world") input: The string need to be printed.
*
* {example} parseAccountingValue("($0.60)") # -0.60.
*/
public static float parseAccountingValue(String value) { if (value == null) { return 0.0f; } float ret = -1; if (value.substring(0, 1).equals("(")) { ret = Float.parseFloat(value.substring(2, value.length()-1)) * -1; } else { ret = Float.parseFloat(value.substring(1, value.length())); } return ret; }

 


Accepted Solutions
Five Stars

Re: Help Diagnosing Null Pointer

Found the problem. It looked like it was choking on the 152nd line of my csv, but the problem was actually with the 153rd line. One of my columns was missing data and that was necessary because I had an index on the corresponding column on target database.


All Replies
Five Stars

Re: Help Diagnosing Null Pointer

Found the problem. It looked like it was choking on the 152nd line of my csv, but the problem was actually with the 153rd line. One of my columns was missing data and that was necessary because I had an index on the corresponding column on target database.

Moderator

Re: Help Diagnosing Null Pointer

Hello,

Thanks for posting that you have resolved your issue.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.