[Possible Bug] SoapUI 5 is setting default proxyselector to null
Hello,
first off I'm not sure if this is the right place to report the issue. I did not find a bugtracker or so, so I'm posting this here. Sorry for any inconvenience.
I'm using SoapUI 5 in a java project on Windows 7 with java SDK 1.7.
Used Jar-versions (using maven):
SoapUI Pro v 5.1.2 (soapui-pro-maven-plugin)
Selenium 2.45 is used (selenium-java)
httpclient 4.3.6 is used
When using SoapUI and selenium, selenium is not able to communicate with its webdriver (it does so via apache httpclient).
Reproduction:
WsdlProject wsdlProject = new WsdlProject(""); WebDriver driver = new FirefoxDriver();
Leads to:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26' System info: host: 'xxx', ip: 'XXX.XXX.XXX.XXX', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_75' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:182) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95) at my.project.selenium.webdriver.test.foo(awda.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) at org.testng.internal.Invoker.invokeMethod(Invoker.java:696) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:882) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1189) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:348) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305) at org.testng.SuiteRunner.run(SuiteRunner.java:254) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)
The reason appears to be that SoapUI is setting the default proxyselector to null.
The issue can be worked around by setting it back:
ProxySelector proxy = ProxySelector.getDefault(); WsdlProject wsdlProject = new WsdlProject(""); ProxySelector.setDefault(proxy); WebDriver driver = new FirefoxDriver();
I filed a bug for selenium (https://github.com/SeleniumHQ/selenium/issues/388) they think its an issue with SoapUI so I'm writing this post.
peidong-hu had a simmilar issue in selenium-standalone-server-plugin:
https://github.com/Ardesco/selenium-standalone-server-plugin/issues/23
Additional Info:
Code:
@Test public void foo() throws XmlException, IOException { ProxySelector proxy = ProxySelector.getDefault(); System.out.println("BEFORE: " + ProxySelector.getDefault()); try { WsdlProject wsdlProject = new WsdlProject("XXX"); } catch (SoapUIException e) { e.printStackTrace(); } System.out.println("AFTER: " + ProxySelector.getDefault()); ProxySelector.setDefault(proxy); WebDriver driver = new FirefoxDriver(); }
Result:
[TestNG] Running: BEFORE: sun.net.spi.DefaultProxySelector@146d950 11:23:04,657 WARN [SoapUI] Missing folder [XXX] for external libraries 11:23:04,974 INFO [DefaultSoapUICore] initialized soapui-settings from [XXX] 11:23:06,021 INFO [WsdlProject] Loaded project from [XXX] AFTER: null =============================================== Custom suite Total tests run: 1, Failures: 0, Skips: 0 =============================================== Disconnected from the target VM, address: '127.0.0.1:53425', transport: 'socket' Process finished with exit code 0