I am trying to Automate RestApi By using java, but, ia m facing an issue

package restAssured_automation_weatherReport;
import io.restassured.RestAssured;

import io.restassured.http.Method;

import io.restassured.response.Response;

import io.restassured.specification.RequestSpecification;
public class WeatherReport {
public static void main(String[] args){

RestAssured.baseURI="http://restapi.demoqa.com/utilities/weather/city";

RequestSpecification httpRequest=RestAssured.given();

Response response=httpRequest.request(Method.GET,"/Hyderabad");

String reponcexml=response.getBody().asString();

System.out.println("Response body :"+reponcexml);

}

}

 

While i am trying with above code , it’s throwing below error…..

 

Exception in thread “main” java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at io.restassured.RestAssured.<clinit>(RestAssured.java:346)
at restAssured_automation_weatherReport.WeatherReport.main(WeatherReport.java:13)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 14 more

Default Asked on September 17, 2018 in Program QA Automation.
Add Comment
  • 1 Answer(s)

    Hi buddy,

    just add all the jar files mentioned in the Rest Assured tutorial , i did the same things. everything works fine for me.

     

    if still same issue., keep us posted, will let u know the solution.

    Default Answered on September 18, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.