java.lang.NoClassDefFoundError: org/apache/http/client/config/RequestConfig

9.8k views Asked by At

I imported Parse4j to my project.

My project has the following tutorial lines:

Parse.initialize("xyz", "abc");
ParseObject team = new ParseObject("GameScore");
team.put("score", 1337);
team.put("playerName", "Neymar");
team.save();

For the last line, the following error is thrown:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/config/RequestConfig
    at org.parse4j.command.ParseCommand.<clinit>(ParseCommand.java:29)
    at org.parse4j.ParseObject.save(ParseObject.java:443)
    at Main.main(Main.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.config.RequestConfig
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 8 more

Not sure how this is fixed. Any help is appreciated.

1

There are 1 answers

1
Karan On

Add the following to your pom.xml:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.3</version>
</dependency>