Question

I have one application which needs to have httpclient-4.2.5.jar library to run correctly. I also want to use HtmlUnit library (ver. 2.12). It fails (I think) because of library conflicts (between httpclient-4.2.5.jar and htmlunit-2.12.jar)

Here is output from my log, but I do not understend too much what it says to me because I do not call any of this methods in log...

Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException:   org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext()
    at  com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.createSSLContext(HtmlUnitSSLSocketFactory.java:119)
    at com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.<init>(HtmlUnitSSLSocketFactory.java:102)
    at com.gargoylesoftware.htmlunit.HtmlUnitSSLSocketFactory.buildSSLSocketFactory(HtmlUnitSSLSocketFactory.java:77)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.configureHttpsScheme(HttpWebConnection.java:608)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClient(HttpWebConnection.java:555)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClient(HttpWebConnection.java:518)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:155)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1486)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1403)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:305)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:359) 
Était-ce utile?

La solution 2

Well, the only solution which works for me is to downgrade to httpclient 4.2 - http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.2

Autres conseils

It is all very simple. HtmlUnit makes use of a private method in HttpClient code through refection:

http://sourceforge.net/p/htmlunit/code/8377/tree/trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HtmlUnitSSLSocketFactory.java#l113

The method in question was removed in version 4.2.4. See HTTPCLIENT-1320

promote the htmlunit version to 2.15 would fix the problem. worked for me

Quickly checked the "org.apache.http.conn.ssl.SSLSocketFactory" class documentation and there's no such "createDefaultSSLContext()" method there.

I had this problem because I wanted to use WebClient in Selenium.

I upgraded Selenium from 2.33.0 to 2.45.0 and WebClient worked fine afterwards.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top