Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi,
I am trying to add a new stream entry with a user who is not Administrator but I get this error:
Unable to Invoke Service AddStreamEntry on ErrorStream : null
In my Logs I have those two errors:
ErrorCode(3567b45a-99d2-488d-a832-f04463bb67a0), Cause(null), Reason(Access was attempted on a null reference variable.), Possible Resolutions(Remove the reference to the null variable within your extension code.)
[context: com.thingworx.webservices.context.HttpExecutionContext@1e4b87eb][message: Unable to Invoke Service AddStreamEntry on ErrorStream : null]
I set my permissions on stream like this:
AddStreamEntry
Solved! Go to Solution.
Fabio, Form your error log, The null reference to the stream indicates that there is a visibility issue here. Although you have given visibility access to the stream, you may have missed giving access at the persistence provider level. Go to persistence provider and add the User org there and see if it resolves the issue. Rest everything seems normal from what you have told!
Hi Fabio, does it work when you attempt to log entry as an Admin user?
Yes, when I am Administrator it works fine.
If I'm a regular user, it doesn't
Could you please enable the Stack Tracing in the Logging Subsystem and execute the service again, once done check for the error stack in the ErrorLog together with the ScriptLog and may be also share the stack here.
Thanks.
In application log
[context: com.thingworx.webservices.context.HttpExecutionContext@74ef3fad][message: Unable to Invoke Service AddStreamEntry on ErrorStream : null]
ErrorCode(fd3d2737-b8a0-4cf5-b0e6-ec8e898bc832), Cause(null), Reason(Access was attempted on a null reference variable.), Possible Resolutions(Remove the reference to the null variable within your extension code.)
in Script log no errors shown
(I forgot to say: I'm using TW version 8)
Fabio, was there nothing in the ErrorLog after you enabled the StackTracing in LoggingSubsystem?
No, nothing
Hello, I still have this issue.
Does anyone have any suggestion?
Fabio,
You will need to create a Wrapper service that calls the AddStreamEntry inside the wrapper.
Give the user runtime permission to execute the Wrapper and add System to the runtime permission
Does this make sense, If not can your provide more info
I did. I created a service named "AddItem"
The code is this:
var innerValues = me.CreateValues();
innerValues.Time = data.Time;
innerValues.Thing = data.Thing;
innerValues.Service = data.Service;
innerValues.Method = data.Method;
innerValues.Line = data.Line;
innerValues.ErrorMessage = data.ErrorMessage;
var newEntry = {
sourceType: undefined,
values: innerValues,
location: undefined,
source: undefined,
timestamp: undefined,
tags: undefined
};
me.AddStreamEntry(newEntry);
And my result is:
java.lang.NullPointerException: null |
Visibility permission is Everyone.
Runtime is to all Users
I know the questions maybe simple but this helps in getting an understanding
Can you show the permissions on the Stream and where the service is. Also as I look more at the code
can you add more debugging - where is the data coming from - I assume input params
Stream (Thing template)
AddStreamEntry (Users)
Where is data variable coming from?
This service is called in the catch of any service in case of error.
try{
//code
}catch(err){
Time = new Date();
Thing = me.name;
Service = "This service name";
Method = data.Method;
Line = err.lineNumber;
ErrorMessage = err.message;
}
but I have the same problem also if I call the service from the composer
Fabio, Form your error log, The null reference to the stream indicates that there is a visibility issue here. Although you have given visibility access to the stream, you may have missed giving access at the persistence provider level. Go to persistence provider and add the User org there and see if it resolves the issue. Rest everything seems normal from what you have told!
Fabio,
Ragu is correct - I simulated your issue and got the null pointer and was working the permissions and did not think about the visibility to the persistence provider. Version 8 by default takes visibility of everybody out of all collections
Below shows my configuration - Which I know you know - this just if anybody is reviewing the post
addItem service permissions
Persistence Providers permission
You can also do a quick viability check via a test user using incognito
http://localhost/Thingworx/PersistenceProviders
That is a quick why to check visibility