Maven issue with REST Assured, and how I fixed it

865 views
Skip to first unread message

Nick

unread,
Jun 16, 2011, 12:02:54 PM6/16/11
to REST assured
Hi,
I had the following issue with Maven 2 getting Rest-assured to work. I
am somewhat of a Maven newbie so it took me a while to figure it out.
For any command, such as:

given()
.parameters("emailId", "bademai...@test.com", "password",
"badpassword", "imei", imei, "partnerCode", partnerCode)
.expect().body("errors", equalTo("Unable to validate account"))
.when().post(accountsContext);

I got an exception (always the same one):

java.lang.NoSuchFieldError: tokenTypeToASTClassMap
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.buildTokenTypeASTClassMap(GroovyRecognizer.java:
14165)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.<init>(GroovyRecognizer.java:
460)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.<init>(GroovyRecognizer.java:
465)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.make(GroovyRecognizer.java:
222)
....
at
com.jayway.restassured.assertion.JSONAssertion.getResult(JSONAssertion.groovy:
33)
... (much more...)

Using this as dependency:

<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>

The solution was to make sure that this dependency appears FIRST in
the pom.xml, as suggested by Johan. If your project uses some of the
same libraries that rest-assured uses, it could cause conflicts if
there are different versions. I also had to include this right after
the above dependency:

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>

Maven was for some reason unable to resolve this one on its own. Hope
that helps if anyone encounters this problem.

Johan Haleby

unread,
Jun 16, 2011, 2:43:39 PM6/16/11
to rest-a...@googlegroups.com
Thanks for letting us and I'm glad that you were able to resolve it.

/Johan

Reply all
Reply to author
Forward
0 new messages