Martin Dürrmeier
Martin Dürrmeier

Reputation: 1683

RestAssured with Junit4 throws ClassNotFoundException: org.apache.http.client.methods.HttpPatch

I'm trying to setup a simple rest-assured testcase with Junit 4.8 and maven3 with dependencies

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

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8</version>
        <scope>test</scope>
    </dependency>

But this throwns me

Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpPatch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 34 more

I used doc from https://code.google.com/p/rest-assured/wiki/GettingStarted And checked https://code.google.com/p/rest-assured/wiki/FAQ

Any help very welcome

Upvotes: 1

Views: 2888

Answers (2)

euniceadu
euniceadu

Reputation: 858

I know this question is very old but I had a similar problem and I solved it by adding the correct version of httpclient. The version of rest-assured I am using is 2.3.4 so the correct version of httpclient for it is 4.3.5 . With regards to this question, since you are using rest-assured version 1.8.0, the correct version of httpclient to use is 4.2.1

Upvotes: 0

Martin D&#252;rrmeier
Martin D&#252;rrmeier

Reputation: 1683

I had a dependency to a parent pom which caused the ClassNotFound Exception, after removing the dependency it works.

Upvotes: 1

Related Questions