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

AddStreamEntries error :Wrapped java.lang.NullPointerException

Highlighted
Regular Member

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);

 

 

 

 

 

Tags (1)
10 REPLIES 10

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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

 

Anyone out there?

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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.

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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.

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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.

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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

 

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

What does you mean?

Re: AddStreamEntries error :Wrapped java.lang.NullPointerException

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.