简体   繁体   中英

org/apache/http/protocol/HTTP error when using Rest Assured

my code snipped is:

@Test
public void connectionTestWithRestAssured() {
     given().
        contentType("application/json").
    when().
        get("http://localhost:8080/dictionaries").
    then().
        statusCode(200);
}

getting following error:

java.lang.NoClassDefFoundError: org/apache/http/protocol/HTTP
    at com.jayway.restassured.config.EncoderConfig.<init>(EncoderConfig.java:48)
    at com.jayway.restassured.config.RestAssuredConfig.<init>(RestAssuredConfig.java:41)
    at com.jayway.restassured.RestAssured.<clinit>(RestAssured.java:423)
    at com.adobe.test.dictionary.GetDictionary.connectionTestWithRestAssured(GetDictionary.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)

I have tried adding these lib: httpcore,httpclient, httpmime but its not working at all please help.

在此处输入图片说明

Simplest way to fix this is to "Add Library" -> "Server runtime" -> choose your server, eg WildFly 10.0 Runtime

If you want to see included jars you could see them in Package Explorer and even extract/copy them to project folder by context action "Copy Classpath Libraries"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM