【问题标题】:java.lang.NoClassDefFoundError: org/apache/http/nio/conn/NHttpClientConnectionManagerjava.lang.NoClassDefFoundError: org/apache/http/nio/conn/NHttpClientConnectionManager
【发布时间】:2015-10-27 08:58:55
【问题描述】:

我目前有这些罐子:

  • httpasyncclient-4.0-beta3.jar
  • httpclient-4.5.jar
  • httpclient-cache-4.5.jar
  • httpclient-win-4.5.jar
  • httpcore-4.3.jar
  • httpcore-nio-4.1-beta2.jar
  • httpmime-4.2.3.jar
  • slf4j-api-1.7.12.jar

我的错误来自的java方法是:

 private HttpResponse<JsonNode> jwtAuthPost(String assertion) throws UnirestException {
    HttpResponse<JsonNode> jsonResponse = Unirest.post(AUTH_URL)
              .header("accept", "application/json")
              .field("grant_type", JWT_GRANT_TYPE)
              .field("client_id", this.clientId)
              .field("client_secret", this.clientSecret)
              .field("assertion", assertion)
              .asJson();  //error here

    return jsonResponse;
}

我猜我在某处缺少一个插件,但我似乎无法在任何地方找到它。

错误日志的其余部分

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/nio/conn/NHttpClientConnectionManager
  at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
  at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:134)
  at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)

【问题讨论】:

  • HttpAsyncClient 应该有 NHttpClientConnectionManager。但问题是它在运行时类路径中不可用。你在用 maven 吗?
  • 我没有使用 maven,我可能应该使用。

标签: java maven jar https jwt


【解决方案1】:

包括

httpasyncclient-4.0-beta4.jar

而不是

httpasyncclient-4.0-beta3.jar

见:http://www.java2s.com/Code/Jar/h/Downloadhttpasyncclient40beta4jar.htm

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    相关资源
    最近更新 更多