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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

java.lang.Exception: Invalid Global Session Parameter [null]

paripirala
1-Newbie

java.lang.Exception: Invalid Global Session Parameter [null]

Hi,

1. I created 2 properties in GlobalSessionProperties ThingShape.

2. From Thingworx composer, I go to CurrentSessionInfo Resource.

3. I select the service 'GetGlobalSessionValues' and execute it. It displays the 2 properties and their default values.

4. Next I select 'SetGlobalSessionStringValue' and execute it with one of the properties created in step 1 giving a different value. It successfully executes.

5. I select the service 'GetGlobalSessionValues' and execute it. It displays the updated properties.


Now I go into my Authenticator extension and execute the same steps from 2 - 4, it throws "java.lang.Exception: Invalid Global Session Parameter [null]" at step 4. Here are the details:

Step 2) Resource sessionInfo = (Resource) EntityUtilities.findEntity("CurrentSessionInfo", ThingworxRelationshipTypes.Resource);

Step 3) InfoTable sessionShape = sessionInfo.processServiceRequest("GetGlobalSessionValues", null);

             printInfoTable(sessionShape); // Convenience method to print ValueCollection.

              This does not print the 2 properties I create.

Step 4) Set the value

ValueCollection params = new ValueCollection();

params.SetStringValue("Property1", value);

sessionInfo.processServiceRequest("SetGlobalSessionStringValue", params);

The above line throws "java.lang.Exception: Invalid Global Session Parameter [null]".

Any pointers appreciated.

Thanks

Pavan

1 ACCEPTED SOLUTION

Accepted Solutions

The exception is happening because the processServiceRequest call was not invoked in the user's context. When we set the user's context and executed it there was not exception.

However the value is not stored and it is not being returned in GetGlobalSessionValues - I'll raise a different post for this.

Thanks

View solution in original post

3 REPLIES 3

Hi Pavan,

Do you see any different behavior trying the following?

For Step 2, try using this line instead:

     SessionInfo sessionInfo= (SessionInfo) EntityUtilities.findEntity("CurrentSessionInfo", ThingworxRelationshipTypes.Resource);


Thanks,

Rob


Thanks Rob for the response. I tried that and still it throws the same exception.

The exception is happening because the processServiceRequest call was not invoked in the user's context. When we set the user's context and executed it there was not exception.

However the value is not stored and it is not being returned in GetGlobalSessionValues - I'll raise a different post for this.

Thanks

Top Tags