Wednesday, June 17, 2015

java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslcontext

When you try to use `HtmlUnit`,

you might encounter the following exception:

java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslcontext

You're using httpcomponents 4.5.

If you don't need the version,

downgrade it to 4.4.1 as follows:

    testCompile("org.apache.httpcomponents:httpclient:4.4.1")
    testCompile("org.apache.httpcomponents:httpmime:4.4.1")

References:
http://htmlunit.10904.n7.nabble.com/HtmlUnit-htmlunit-bugs-1692-Update-to-HttpComponents-4-5-td36318.html

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I have this problem, I downgraded to 4.4.1 with maven, but it does not work. What did you mean by testCompile("org.apache.httpcomponents:httpclient:4.4.1") ?

    ReplyDelete
  3. Thanks a lot! worked for me!

    ReplyDelete