I my project, am using an External jar dependent on ‘org.json’ latest version ‘20190722’. As Katalon Studio uses ‘org.json’ with version 20140107, executing tests its throwing error.
2020-05-17 17:38:13.278 ERROR c.k.katalon.core.main.TestCaseExecutor - Test Cases/simulationprocess FAILED.
Reason:
java.lang.NoSuchMethodError: org.json.JSONArray.forEach(Ljava/util/function/Consumer;)V
How Can I resolve this issue… ?
Please any suggestions to resolve this dependency, would be really help ful
You can read 20160221 API of org.json at
https://stleary.github.io/JSON-java/org/json/JSONArray.html
I could see that older versions of org.json.JSONArray
does not implement forEach
method.
Then, in the old days with the old version, how did they iterate over the child nodes of org.json.JSONArray
object?
An old Stackoverflow post https://stackoverflow.com/questions/4784874/is-it-possible-to-iterate-through-jsonarray tells what they did. It is like this:
for (int i = 0; i < arr.length(); i++) {
arr.getJSONObject(i);
}
You can change your test script so that it uses the classic “for with index” instead of “forEach”, can’t you? If you do the change, your test script may successfully run in Katalon Studio with older version of org.json.
@SRamagiri
You cannot enforce your Katalon project to use another org.json lib right now. Please share us how is important to upgrade this lib or create a feature request via this link: https://github.com/katalon-studio/katalon-studio. Our teams will review later.
Thanks