We’re noticing that the ability to do JSON schema validation using using everit’s JSON validator referenced here appears to have broken sometime after 5.9.0.
Error message when running the same script in v6.0.4 on:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoSuchMethodError: org.json.JSONObject.toMap()Ljava/util/Map;
at com.api.EveritValidator.invokeMethod(EveritValidator.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)
at Crud_v3.11 - Retrieve campaign, validate JSON.run(Crud_v3.11 - Retrieve campaign, validate JSON:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:342)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:333)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:312)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:304)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:238)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1555593737838.run(TempTestCase1555593737838.groovy:21)
Caused by: java.lang.NoSuchMethodError: org.json.JSONObject.toMap()Ljava/util/Map;
at org.everit.json.schema.loader.SchemaLoader$SchemaLoaderBuilder.schemaJson(SchemaLoader.java:187)
at org.everit.json.schema.loader.SchemaLoader.load(SchemaLoader.java:259)
at org.everit.json.schema.loader.SchemaLoader.load(SchemaLoader.java:245)
at org.everit.json.schema.loader.SchemaLoader$load.call(Unknown Source)
at com.api.EveritValidator.verifyJsonSchema(EveritValidator.groovy:23)
at com.api.EveritValidator.invokeMethod(EveritValidator.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)
at Script1540201659864.run(Script1540201659864.groovy:25)
... 11 more
In the linked discussion, the response is retuned as an Array and that’s why you need the JSONArray. This API will return a Json Object.
The API response is kinda like this:
{
“Name”: “test”,
“DateCreated”: “2019-04-10T12:36:51”,
“StartDate”: “2019-04-12T21:00:00”,
“EndDate”: “2019-04-13T20:59:00”,
“LastUpdated”: “2019-04-15T12:45:32”
}
@Morgan@Mihai_Augustin_Sarat
i will look into it … i no longer have kata installed but will do it tomorrow if the time allows
most probably with the new version some .jar’s are conflicting …
@Russ_Thomas is a different case now … but that reminds me that i promised to make a coherent tutorial on this matter … will do one day …
perhaps i havr to re-write the keyword to make it aware of the response type and choose array or object … that will save some people from headache
@Morgan can you please edit your post and re-format the log as /code mark-up to make it more readable? i think the forum plaform is js just using markdown, you have hints in the edit area and preview. pleaaase
I did some research, and, as I was afraid the issue is created by the org.json library being added into the Katalon since … I don’t know exactly what version.
E.g, opening a sample project with Katalon 5.9.0 the following is generated into the project .classpath file (stripped content to the lines we are interested):
Note that, in addition to the org.json lib we import into the project, we have also org.json_20140107.0.0.jar, the one used by katalon himself, which is an older version.
Unfortunately, Katalon is attempting to load that one … and not the one we need, therefore the error above.
So … we may have to summon other jedi master’s to help us in solving it. @devalex88@kazurayam any idea how can we convince katalon to compile/import at the TestCase runtime the right library from the project and not the one from Kata … and only for the keyword/testcase? Attemtping to replace the library in Katalon himself lead to crash, looking into logs looks like plenty of katalon libs depend on that one …
@Mihai_Augustin_Sarat you can try to use jackson untill this get fixed … altough i don’t remember what are the deps of it …
from various logs posted here and there,i think jackson is already present in katalon. you will have to write a new keyword … but you can figure it out. i think it is still one wroted by me in one of the poc projects …