Skip to main content
1-Visitor
August 21, 2017
Solved

Unable to Invoke Service AddStreamEntry

  • August 21, 2017
  • 4 replies
  • 7570 views

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
Best answer by rnayak-2

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!

4 replies

5-Regular Member
August 21, 2017

Hi Fabio, does it work when you attempt to log entry as an Admin user?

fmanniti1-VisitorAuthor
1-Visitor
August 21, 2017

Yes, when I am Administrator it works fine.
If I'm a regular user, it doesn't

5-Regular Member
August 21, 2017

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.

fmanniti1-VisitorAuthor
1-Visitor
January 12, 2018

Hello, I still have this issue.
Does anyone have any suggestion?

16-Pearl
January 12, 2018

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

fmanniti1-VisitorAuthor
1-Visitor
January 12, 2018

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

16-Pearl
January 12, 2018

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

16-Pearl
January 12, 2018

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

16-Pearl
January 12, 2018

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