jscherman
jscherman

Reputation: 6189

HttpClients.createDefault error?

i created a RestUtils library which uses org.apache.httpclient and this is what happens:

i have this fragment of code inside these library:

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

Well happens that first line (createDefault method) works ok when i call this method from "strap" project, but when i call it from "social" project, it fails at these line. This is not throwing any error, but debugging i found this exception:

java.lang.reflect.InvocationTargetException

What could be the reason for createDefault() method fails depending where i call from? Regards

Edit: I found that exception because inside method "invokeMethod()" (some internal method of createDefault()) it gets into this catch:

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

As i said, this doesn't have e.printStackTrace() and i can't add it because i have it as depndency and i am not able to edit it

However, i have a catch where i call createDefaults method and it doesn't print stacktrace neither

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

Upvotes: 0

Views: 3739

Answers (1)

user1746277
user1746277

Reputation: 71

In my case the problem was due to forgetting to include the library commons-logging-1.2.jar

Upvotes: 1

Related Questions