Forum Discussion

jatinkarvir's avatar
6 years ago

com.jayway.jsonpath.PathNotFoundException: Array index [Ljava.lang.String;@4e711deb not found

Hi,

I am new to SoapUI/Json/groovy script. I am trying to run a groovy script - shown below, but the system is showing error message as mentioned below:

 

Groovy script (pasting exactly from the script along with the line#):

===========

 

  1. import static com.jayway.jsonpath.JsonPath.parse
  2.  
  3. def navigatorModelResponse = context.expand('${getNavigatorModel#Response}')
  4.  
  5. def propertiesStep = testRunner.testCase.getTestStepByName("timestamp.properties");
  6. def timestampWidgetName = context.expand(propertiesStep.getPropertyValue("DefaultTimestampWidgetName"))
  7.  
  8. def json = parse(navigatorModelResponse)
  9. def token = json.read('$.constraintData[?(@.widgetLabel==' + timestampWidgetName + ')].token[0]')
  10. testRunner.testCase.setPropertyValue("serializedToken", token)

 

Error message:

============

"com.jayway.jsonpath.PathNotFoundException: Array index [Ljava.lang.String;@4e711deb not found in path error at line: 9"

 

I looked into line: 9 which is :

def token = json.read('$.constraintData[?(@.widgetLabel==' + timestampWidgetName + ')].token[0]')

and try to analyze more and found that the response from 'getNavigatorModel#Response' (line#3), has '"constraintData": [],' but there is NO such element as 'token[0]'. Part of the response is shown below, which shows the 'constraintData[]' as blank:

 

{
"workspaces": [],
"toolbars": [{"actions": [ {
"handler": {"className": "com.kronos.wfc.handler"},
"id": "actionSignOut",
"label": "Sign Out"
}]}],
"sessionModel": {
"signOffUrl": "/htmlnavigator/logoff",
"signOffSsoUrl": "/htmlnavigator/logoff",
"isSSOMode": false,
"isSSOTimeout": false,
"showSSOTimeoutWarning": false,
"navigatorSSOTimeOutURL": "/wfc/logonWithUID",
"navigatorSSOSignOffURL": "/wfc/htmlnavigator/logoff",
"hideSSOSignOut": false
},
"workspaceView": false,
"widgetView": false,
"navigatorView": false,
"delayLoadTime": 6000,
"containerMinWidth": 0,
"containerMinHeight": 0,
"constraintData": [],
"constraintRules": {
"constrained_links": [
"Timecard",
"SPEC:-107",
"SPEC:-108",
"Leave Case",
"Attendance Editor",
"REPORTS",
"Schedule Editor"
],
"user_threshold": ["70"]
},

 

I am NOT sure, how resolve this issue. Any help is appreciated.

 

Thanks,

Jatin.

 

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3
    No voice in JsonPath.
    Would it be possible to post full json along with what data needs to be extracted so that alternative can be possible.