cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

AddStreamEntries error :Wrapped java.lang.NullPointerException

plaban
6-Contributor

AddStreamEntries error :Wrapped java.lang.NullPointerException

Hi All,

I am facing "Wrapped java.lang.NullPointerException " error while trying to execute AddStreamEntries to add records to stream.

 TW Version 8.3

 

Please find below the code

 

var column = "FlowRate";
var params = {
t: result1 /* INFOTABLE */,
columns: column /* STRING */,
aggregates: "AVERAGE" /* STRING */,
groupByColumns: "date" /* STRING */
};
// result: INFOTABLE
//var resultAggregate = Resources["InfoTableFunctions"].Aggregate(params);
var result = Resources["InfoTableFunctions"].Aggregate(params);

var resultLength = result.rows.length;

//logger.warn(resultLength);
var Values = Things["FlowRateAverage"].CreateValues();
for (var m=0; m < resultLength; m++) {
var resultRow = result.rows[m];
var newValues = new Object();
newValues.date = resultRow.date;
newValues.FlowRate = resultRow.AVERAGE_FlowRate;
Values.AddRow(newValues);
}

result = Values;

var paramsForAddStreamEntryService = {
sourceType: undefined /* STRING */,
values: Values /* INFOTABLE*/,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
timestamp: new Date() /* DATETIME */,
tags: undefined /* TAGS */
};

Things["FlowRateAverage"].AddStreamEntries(paramsForAddStreamEntryService);

 

 

 

 

 

10 REPLIES 10
ague
12-Amethyst
(To:plaban)

I've got the same issue. Checked everything I could think of. 

 

Anyone out there?

But the problem it's on the AddStream or on Aggregator? please add a try/catch in both cases to check where it really fails.

plaban
6-Contributor
(To:CarlesColl)

I have used try catch and logs the issue is with addStream.

Then the problem should be on the data, did you list it? Output the data on the service without Adding on the ValueStream. Add a parameter, for instance, onlyList and when set to False don't aggregate but output.

ague
12-Amethyst
(To:CarlesColl)

Does each timestamp entry in a stream HAVE to be unique?

For sure, you can't have two stream entries with the same timestamp on the same source. But still this shouldn't give an error as one will upsert the other.

plaban
6-Contributor
(To:CarlesColl)

I am able to print the data using infotable as o/p type. That worked fine. 

 

What does you mean?

plaban
6-Contributor
(To:CarlesColl)

I meant, I am able to print the list after the aggregation. But the issue comes when I am trying to add it to the stream.

And all data it's ok? or for instance you have a NUMBER baseType column with any empty or alike value?

Top Tags