Ask a Question

getting java.lang.classcastexception at groovy step in Ready API

majji
Occasional Visitor

getting java.lang.classcastexception at groovy step in Ready API

I am getting java.lang.classcastexception while running the groovy step in Ready API tool

 

Sample Code:

1. Parsing the soapui JSON response

2. Reading node values from the hierarchy by running the loop

   def PN=jsonresponse.result.hr1[1].hr2[1].hr

  for (i=0;i<=PN.size()-1;i++{

    if (PN[i].containsKey("name")){

     log.info PN[i].getAt("name")

}

}

3. while iterating, some times,for first iteration it is executing and for remaining loops it is giving classcastexception at the step " if (PN[i].containsKey("name")){"

 

Most of the times script giving error without running single iteration.

 

Please help me what could be the issue in this code?

 

2 REPLIES 2
TanyaYatskovska
SmartBear Alumni (Retired)

Hi Majji,

 

Try debugging your code to identify the cause of this exception. Refer to this article explaining how to debug Groovy scripts:

http://readyapi.smartbear.com/features/groovy/start

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



nmrao
Champion Level 3

Please show raw response.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: