BruceyBandit :
I am trying to retrieve details from a node within a json path using rest assured and java. However I keep getting the following error:
java.lang.NoClassDefFoundError: org/apache/groovy/io/StringBuilderWriter
at io.restassured.internal.path.json.ConfigurableJsonSlurper.parseObject(ConfigurableJsonSlurper.groovy:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at io.restassured.internal.path.json.ConfigurableJsonSlurper.parse(ConfigurableJsonSlurper.groovy:105)
at io.restassured.internal.path.json.ConfigurableJsonSlurper$parse.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at io.restassured.internal.path.json.ConfigurableJsonSlurper.parseText(ConfigurableJsonSlurper.groovy:83)
at io.restassured.path.json.JsonPath$4$1.method(JsonPath.java:949)
at io.restassured.path.json.JsonPath$ExceptionCatcher.invoke(JsonPath.java:984)
at io.restassured.path.json.JsonPath$4.doParseWith(JsonPath.java:951)
at io.restassured.path.json.JsonPath$JsonParser.parseWith(JsonPath.java:1031)
at io.restassured.path.json.JsonPath.get(JsonPath.java:202)
at uk.co.hermes.cucumber.utils.xxx.postAccessToken(xxx.java:86)
at uk.co.hermes.cucumber.utils.xxx.unblockUser(xxx.java:27)
I know the issue is with this line in the code:
String token = jsonPathEvaluator.get("token");
How can this be fixed?
public void postAccessToken(){
RestAssured.baseURI = "https://xxx";
JSONObject requestJsonBodyParams = new JSONObject();
requestJsonBodyParams.put("test", "xxx");
Response response = RestAssured.given()
.contentType(jsonContentType).
body(requestJsonBodyParams.toString()).
when().
post("/");
Assert.assertEquals(response.statusCode(), 200);
JsonPath jsonPathEvaluator = response.jsonPath();
String token = jsonPathEvaluator.get("token");
}
UPDATE:
Esha Singh :
I was facing the same error and after deep diving in POM.xml i figured out there were multiple groovy dependency however removing this :
Just worked like a charm. I am not sure if that would help but yes try removing multiples groovy dependency.