I have this exception testng: Caused by: java.lang.NoSuchMethodError: org.apache.http.params.HttpConnectionParams.setSoReuseaddr

1

What should I do to avoid this exception when I try to run my selenium tests with testNG.

  

org.testng.TestNGException: Can not instantiate class   TestCaseJuntos.BeforeandAfterclass at   org.testng.internal.ObjectFactoryImpl.newInstance (ObjectFactoryImpl.java:40)     at   org.testng.internal.ClassHelper.createInstance1 (ClassHelper.java:382)     at   org.testng.internal.ClassHelper.createInstance (ClassHelper.java:295)     at   org.testng.internal.ClassImpl.getDefaultInstance (ClassImpl.java:118)     at org.testng.internal.ClassImpl.getInstances (ClassImpl.java:183) at   org.testng.internal.TestNGClassFinder. (TestNGClassFinder.java:128)     at org.testng.TestRunner.initMethods (TestRunner.java:416) at   org.testng.TestRunner.init (TestRunner.java:242) at   org.testng.TestRunner.init (TestRunner.java:212) at   org.testng.TestRunner. (TestRunner.java:166) at   org.testng.remote.support.RemoteTestNG6_9_7 $ 1.newTestRunner (RemoteTestNG6_9_7.java:26)     at   org.testng.remote.support.RemoteTestNG6_9_7 $ DelegatingTestRunnerFactory.newTestRunner (RemoteTestNG6_9_7.java:59)     at   org.testng.SuiteRunner $ ProxyTestRunnerFactory.newTestRunner (SuiteRunner.java:587)     at org.testng.SuiteRunner.init (SuiteRunner.java:161) at   org.testng.SuiteRunner. (SuiteRunner.java:114) at   org.testng.TestNG.createSuiteRunner (TestNG.java:1290) at   org.testng.TestNG.createSuiteRunners (TestNG.java:1277) at   org.testng.TestNG.runSuitesLocally (TestNG.java:1131) at   org.testng.TestNG.run (TestNG.java:1048) at   org.testng.remote.AbstractRemoteTestNG.run (AbstractRemoteTestNG.java:126)     at org.testng.remote.RemoteTestNG.initAndRun (RemoteTestNG.java:152)     at org.testng.remote.RemoteTestNG.main (RemoteTestNG.java:57) Caused   by: java.lang.reflect.InvocationTargetException at   sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)     at   sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)     at   sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance (Constructor.java:423)     at   org.testng.internal.ObjectFactoryImpl.newInstance (ObjectFactoryImpl.java:29)     ... 21 more Caused by: java.lang.NoSuchMethodError:   org.apache.http.params.HttpConnectionParams.setSoReuseaddr (Lorg / apache / http / params / HttpParams; Z) V     at   org.openqa.selenium.remote.internal.HttpClientFactory.getHttpParams (HttpClientFactory.java:84)     at   org.openqa.selenium.remote.internal.HttpClientFactory. (HttpClientFactory.java:52)     at   org.openqa.selenium.remote.HttpCommandExecutor. (HttpCommandExecutor.java:100)     at   org.openqa.selenium.remote.HttpCommandExecutor. (HttpCommandExecutor.java:81)     at   org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start (NewProfileExtensionConnection.java:81)     at   org.openqa.selenium.firefox.FirefoxDriver.startClient (FirefoxDriver.java:244)     at   org.openqa.selenium.remote.RemoteWebDriver. (RemoteWebDriver.java:110)     at   org.openqa.selenium.firefox.FirefoxDriver. (FirefoxDriver.java:190)     at   org.openqa.selenium.firefox.FirefoxDriver. (FirefoxDriver.java:183)     at   org.openqa.selenium.firefox.FirefoxDriver. (FirefoxDriver.java:179)     at   org.openqa.selenium.firefox.FirefoxDriver. (FirefoxDriver.java:92)     at   TestCaseJuntos.BeforeandAfterclass. (BeforeandAfterclass.java:23)     ... 26 more

    
asked by Laura Alvarez 29.09.2016 в 20:49
source

1 answer

0

NoSuchMethodError indicates that the program was compiled by calling a method of a class, but during execution the JVM detects that the class of that name it finds does not have that method.

The most common cause is that you are putting an erroneous (usually older) version of the class called in the classpath.

Searching for the % Java_country% , a HttpConnectionParams method appears; Looking at your information we see that:

a) is setSoReuseAddr() .

b) exists since version 4.1 of the library.

For the part of Deprecated there is not much to do, just wait for a new version of the library that calls the method and use the correct method. On the other hand, it is clear that you have to make sure that you use a version of the%% Apache library that is 4.1 or higher.

    
answered by 29.09.2016 в 23:13