3

I am trying to use Unirest-Mashape to build java applications.

This is my code:import com.mashape.unirest.http.*;

import com.mashape.unirest.http.HttpResponse;
import org.apache.http.*;
import org.json.*;
public class request {
    public static void main(String[] args) throws Exception {
        HttpResponse<JsonNode> response = Unirest.get("https://omgvamp-hearthstone-v1.p.mashape.com/cards").header("X-Mashape-Key", "<required>").asJson();
}
}

When I compile my code, It shows no error. But when I run it, it shows the following runtime error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/nio/reactor/IOReactorException at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151) at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131) at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68) at request.main(request.java:18) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.ClassNotFoundException: org.apache.http.nio.reactor.IOReactorException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 9 more

I've got included this clases to my project

But still I am getting the error. Please help me.

1 Answers1

0

You need httpcore-nio also. The Unirest Java section is pretty bad, and is missing most of the dependencies.

Saiyine
  • 1,579
  • 3
  • 15
  • 27