Unable to Invoke Service AddStreamEntry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Unable to Invoke Service AddStreamEntry
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:
- c.t.c.p.ReflectionProcessor
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.)
- c.t.w.BaseService
[context: com.thingworx.webservices.context.HttpExecutionContext@1e4b87eb][message: Unable to Invoke Service AddStreamEntry on ErrorStream : null]
I set my permissions on stream like this:
- Visibility Everyone
- Runtime: Users (Property Read, Service Execute)
- Services
AddStreamEntry
- Services
Solved! Go to Solution.
- Labels:
-
Troubleshooting
- Tags:
- service invoke
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Fabio, does it work when you attempt to log entry as an Admin user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes, when I am Administrator it works fine.
If I'm a regular user, it doesn't
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Fabio, was there nothing in the ErrorLog after you enabled the StackTracing in LoggingSubsystem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
No, nothing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello, I still have this issue.
Does anyone have any suggestion?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Stream (Thing template)
- Visibility: Everyone
- Visibility Instance: Everyone
- Design Time: None
- Design Time Istance: None
- Run time: Users (Property read, Service Execute)
- Run time Instance: Users (Property read, Service Execute)
AddStreamEntry (Users)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Where is data variable coming from?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
