Quantcast

Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver

Achim Mustroph

Hello,

 

I’m trying to open a site under test with Selenium headless by using HTMLUnitDriver. With FirefoxDriver and ChromeDriver the code works but with htmlunitdriver I’m getting the following error:

 

org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver

Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'

System info: host: 'deleted by me', ip: 'deleted by me', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_66'

Driver info: driver.version: HtmlUnitDriver

       at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:688)

       at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$8(HtmlUnitDriver.java:657)

       at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$0(HtmlUnitDriver.java:414)

       at java.lang.Thread.run(Thread.java:745)

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

       at org.apache.commons.lang3.Validate.isTrue(Validate.java:158)

       at org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField(FieldUtils.java:511)

       at com.gargoylesoftware.htmlunit.HttpWebConnection.getField(HttpWebConnection.java:1038)

       at com.gargoylesoftware.htmlunit.HttpWebConnection.createConnectionManager(HttpWebConnection.java:961)

       at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:166)

       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1357)

       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1274)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:382)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304)

       at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:670)

       ... 3 more

 

After looking for the line that causes this error I found this: method in HttpWebConnection:

 

final DnsResolver dnsResolver = getField(builder, "dnsResolver");

 

Finally this method is called:

 

@SuppressWarnings("unchecked")

private static <T> T getField(final Object target, final String fieldName) throws IllegalAccessException {

return (T) FieldUtils.readDeclaredField(target, fieldName, true);

    }

 

I think the reason for that error could be that the field  dnsResolver is private.

 

I’m using the following pom.xml. I already checked that all components use their newest version:

 

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

       <modelVersion>4.0.0</modelVersion>

 

       <groupId>com.example</groupId>

       <artifactId>Project</artifactId>

       <version>1.0</version>

       <packaging>jar</packaging>

 

       <name>PMTestApproach</name>

       <description>Name says everything</description>

 

       <parent>

             <groupId>org.springframework.boot</groupId>

             <artifactId>spring-boot-starter-parent</artifactId>

             <version>1.4.3.RELEASE</version>

             <relativePath /> <!-- lookup parent from repository -->

       </parent>

 

       <properties>

             <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

             <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

             <java.version>1.8</java.version>

       </properties>

       <repositories>

             <repository>

                    <id>jcenter</id>

                    <name>bintray</name>

                    <url>http://jcenter.bintray.com</url>

             </repository>

       </repositories>

       <dependencies>

             <dependency>

                    <groupId>org.springframework.boot</groupId>

                    <artifactId>spring-boot-starter</artifactId>

             </dependency>

             <dependency>

                    <groupId>org.springframework.boot</groupId>

                    <artifactId>spring-boot-starter-test</artifactId>

                    <scope>test</scope>

             </dependency>

             <dependency>

                    <groupId>org.eclipse.paho</groupId>

                    <artifactId>org.eclipse.paho.client.mqttv3</artifactId>

                    <version>1.0.2</version>

             </dependency>

             <dependency>

                    <groupId>org.seleniumhq.selenium</groupId>

                    <artifactId>selenium-java</artifactId>

                    <version>3.4.0</version>

             </dependency>

             <dependency>

                    <groupId>org.testng</groupId>

                    <artifactId>testng</artifactId>

                    <version>6.11</version>

             </dependency>

             <dependency>

                    <groupId>org.apache.httpcomponents</groupId>

                    <artifactId>httpclient</artifactId>

                    <version>4.5.2</version>

             </dependency>

             <dependency>

                    <groupId>org.seleniumhq.selenium</groupId>

                    <artifactId>htmlunit-driver</artifactId>

                    <version>2.26</version>

             </dependency>

       </dependencies>

       <build>

             <plugins>

                    <plugin>

                           <groupId>org.springframework.boot</groupId>

                           <artifactId>spring-boot-maven-plugin</artifactId>

                    </plugin>

             </plugins>

       </build>

</project>

 

Would you please help me solving this problem?

 

Thanks and best regards

 

Achim M.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver

Ronald Brill
Update your HttpClient to 4.5.3.

        RBRi

On Wed, 10 May 2017 11:33:51 +0000 Achim Mustroph wrote:
>
>Hello,
>
>I'm trying to open a site under test with Selenium headless by using HTMLUnitDriver. With FirefoxDriver and ChromeDriver the code works but with htmlunitdriver I'm getting
the following error:

>
>org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver
>Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
>System info: host: 'deleted by me', ip: 'deleted by me', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_66'
>Driver info: driver.version: HtmlUnitDriver
>       at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:688)
>       at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$8(HtmlUnitDriver.java:657)
>       at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$0(HtmlUnitDriver.java:414)
>       at java.lang.Thread.run(Thread.java:745)
>Caused by: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver
>       at org.apache.commons.lang3.Validate.isTrue(Validate.java:158)
>       at org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField(FieldUtils.java:511)
>       at com.gargoylesoftware.htmlunit.HttpWebConnection.getField(HttpWebConnection.java:1038)
>       at com.gargoylesoftware.htmlunit.HttpWebConnection.createConnectionManager(HttpWebConnection.java:961)
>       at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:166)
>       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1357)
>       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient..java:1274)
>       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:382)
>       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304)
>       at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:670)
>       ... 3 more
>
>After looking for the line that causes this error I found this: method in HttpWebConnection:
>
>final DnsResolver dnsResolver = getField(builder, "dnsResolver");
>
>Finally this method is called:
>
>@SuppressWarnings("unchecked")
>private static <T> T getField(final Object target, final String fieldName) throws IllegalAccessException {
>return (T) FieldUtils.readDeclaredField(target, fieldName, true);
>    }
>
>I think the reason for that error could be that the field  dnsResolver is private.
>
>I'm using the following pom.xml. I already checked that all components use their newest version:
>
><?xml version="1.0" encoding="UTF-8"?>
><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven..apache.org/xsd/maven-4.0.0.xsd<http://maven.apache.org/POM/4.0.0%20http:/maven.apache.org/xsd/maven-4.0.0.xsd>">

>       <modelVersion>4.0.0</modelVersion>
>
>       <groupId>com.example</groupId>
>       <artifactId>Project</artifactId>
>       <version>1.0</version>
>       <packaging>jar</packaging>
>
>       <name>PMTestApproach</name>
>       <description>Name says everything</description>
>
>       <parent>
>             <groupId>org.springframework.boot</groupId>
>             <artifactId>spring-boot-starter-parent</artifactId>
>             <version>1.4.3.RELEASE</version>
>             <relativePath /> <!-- lookup parent from repository -->
>       </parent>
>
>       <properties>
>             <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>             <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>             <java.version>1.8</java.version>
>       </properties>
>       <repositories>
>             <repository>
>                    <id>jcenter</id>
>                    <name>bintray</name>
>                    <url>http://jcenter.bintray.com</url<http://jcenter.bintray.com%3c/url>>
>             </repository>
>       </repositories>
>       <dependencies>
>             <dependency>
>                    <groupId>org.springframework.boot</groupId>
>                    <artifactId>spring-boot-starter</artifactId>
>             </dependency>
>             <dependency>
>                    <groupId>org.springframework.boot</groupId>
>                    <artifactId>spring-boot-starter-test</artifactId>
>                    <scope>test</scope>
>             </dependency>
>             <dependency>
>                    <groupId>org.eclipse.paho</groupId>
>                    <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
>                    <version>1.0.2</version>
>             </dependency>
>             <dependency>
>                    <groupId>org.seleniumhq.selenium</groupId>
>                    <artifactId>selenium-java</artifactId>
>                    <version>3.4.0</version>
>             </dependency>
>             <dependency>
>                    <groupId>org.testng</groupId>
>                    <artifactId>testng</artifactId>
>                    <version>6.11</version>
>             </dependency>
>             <dependency>
>                    <groupId>org.apache.httpcomponents</groupId>
>                    <artifactId>httpclient</artifactId>
>                    <version>4.5.2</version>
>             </dependency>
>             <dependency>
>                    <groupId>org.seleniumhq.selenium</groupId>
>                    <artifactId>htmlunit-driver</artifactId>
>                    <version>2.26</version>
>             </dependency>
>       </dependencies>
>       <build>
>             <plugins>
>                    <plugin>
>                           <groupId>org.springframework.boot</groupId>
>                           <artifactId>spring-boot-maven-plugin</artifactId>
>                    </plugin>
>             </plugins>
>       </build>
></project>
>
>Would you please help me solving this problem?
>
>Thanks and best regards
>
>Achim M.
>
>
>
>----< Inline text [text-plain-04.txt] >------------------
>
>------------------------------------------------------------------------------
>Check out the vibrant tech community on one of the world's most
>engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>----< Inline text [text-plain-05.txt] >------------------
>
>_______________________________________________
>Htmlunit-user mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/htmlunit-user
>
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Loading...