0

我创建了一个使用 org.apache.httpclient 的 RestUtils 库,这就是发生的情况:

我在这些库中有这段代码:

    ...
    // Make the request
    this.httpClient = HttpClients.createDefault();
    this.method.setHeaders(headerArray);
    HttpResponse httpResponse = this.httpClient.execute(this.method);
    HttpRestResponse response = new HttpRestResponse();
    ...

当我从“strap”项目调用此方法时,第一行(createDefault 方法)工作正常,但是当我从“social”项目调用它时,它在这些行失败。这不会引发任何错误,但调试我发现了这个异常:

java.lang.reflect.InvocationTargetException

createDefault() 方法失败的原因可能是什么,具体取决于我从哪里调用?问候

编辑:我发现了这个异常,因为在方法“invokeMethod()”(createDefault() 的一些内部方法)中它进入了这个捕获:

catch(InvocationTargetException ite) {
  testResult.setThrowable(ite.getCause());
  testResult.setStatus(ITestResult.FAILURE);
}

正如我所说,这没有 e.printStackTrace() 并且我无法添加它,因为我将它作为依赖项并且我无法编辑它

但是,我有一个问题,我调用 createDefaults 方法,它也不打印堆栈跟踪

    try {
        ...
        // Make the request
        this.httpClient = HttpClients.createDefault();
        ...
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
4

1 回答 1

1

在我的情况下,问题是由于忘记包含库 commons-logging-1.2.jar

于 2015-08-17T11:05:12.390 回答