TimeoutException when instantiating PhantomJSDriver on Linux server

505 views Asked by At

I have strange exception (java.util.concurrent.TimeoutException: null) when trying to create a PhantomJSDriver (ver. 1.9.8) in a backend application on a Linux server. The same application is working without issues on my local Mac.

Exception:

ERROR 12721 --- [http-nio-9095-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] :
Servlet.service() for servlet [dispatcherServlet] in context with
path [] threw exception [Request processing failed; nested 
exception is 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: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: 
'3.12.9-2-ARCH', java.version: '1.8.0_25'
Driver info: driver.version: PhantomJSDriver] 
with root cause 

java.util.concurrent.TimeoutException: null 
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:107)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:96)

Source code causing this issue:

DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
String [] phantomJsArgs = {"--ignore-ssl-errors=yes", "--ssl-protocol=any"};
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomJsArgs);
PhantomJSDriver driver = new PhantomJSDriver(capabilities); // <--- here exception is thrown
1

There are 1 answers

0
dimo414 On

Your actual issue is higher up:

Request processing failed; nested exception is 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.

Selenium is unable to find or start your browser (which would explain why it works on one machine but not another). Is the browser installed on this Linux server? Does the user Selenium is running as have permission to run it?