Skip to main content
Aug 21, 2017 12:30 PM UTC
Solved

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
rnayak-2Answer
Jan 12, 2018 7:25 PM UTC

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!

17 replies

Aug 21, 2017 12:36 PM UTC

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

fmannitiAuthor
Aug 21, 2017 12:38 PM UTC

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

Aug 21, 2017 1:24 PM UTC

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.

fmannitiAuthor
Jan 12, 2018 5:16 PM UTC

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

Jan 12, 2018 5:32 PM UTC

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

fmannitiAuthor
Jan 12, 2018 5:41 PM UTC

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

Jan 12, 2018 5:46 PM UTC

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

Jan 12, 2018 8:12 PM UTC

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

Jan 12, 2018 11:49 PM UTC

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