chromedriver: cannot execute binary file and SEVERE Forwarding newSession on session null to remote with ChromeDriver Selenium through Java

chrisTina :

I have a service that is using selenium to start a chrome webdriver using chrome headless mode. The application is launched through tomcat8. I can run the service without issue locally on my mac.

But once I deployed it to ec2 node through AWS Elastic Beanstalk, the webdriver cannot start properly:

28-Feb-2019 03:32:48.944 SEVERE [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [registerCustomer] in context with path [] threw exception
 org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'ip-172-31-16-234', ip: '172.31.16.234', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.97-74.72.amzn1.x86_64', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at com.christina.insbot.factory.BrowserDriverFactory.createWebDriver(BrowserDriverFactory.java:64)
    at com.christina.insbot.service.InsBot.<init>(InsBot.java:86)
    at com.christina.insbot.service.servlet.RegisterCustomerService.doPost(RegisterCustomerService.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:685)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:13611/status] to be available after 20010 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187)
    ... 36 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 37 more

CATALINA error:

/var/lib/tomcat8/webapps/ROOT/webdriver/chromedriver: /var/lib/tomcat8/webapps/ROOT/webdriver/chromedriver: cannot execute binary file
28-Feb-2019 03:32:48.926 SEVERE [Forwarding newSession on session null to remote] org.openqa.selenium.os.OsProcess.checkForError org.apache.commons.exec.ExecuteException: Process exited with an error: 126 (Exit value: 126)

The way I start the webdriver is like this:

        ChromeOptions options = new ChromeOptions();
        // "--headless",
        options.addArguments("--disable-gpu", "--window-size=1920,1200",
                "--ignore-certificate-errors", "--silent");

        if (useHeadlessMode) {
            options.addArguments("--headless");
        }


        System.setProperty("webdriver.chrome.driver", EnvironmentInitialization.obtainChromeDriverPath());

        webDriver = new ChromeDriver(options);
DebanjanB :

This error message...

28-Feb-2019 03:32:48.944 SEVERE [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [registerCustomer] in context with path [] threw exception
 org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'ip-172-31-16-234', ip: '172.31.16.234', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.97-74.72.amzn1.x86_64', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver

...implies that your program was unable to initiate/spawn a new ChromeDriver service in headless mode.

Further, this error message...

/var/lib/tomcat8/webapps/ROOT/webdriver/chromedriver: /var/lib/tomcat8/webapps/ROOT/webdriver/chromedriver: cannot execute binary file
28-Feb-2019 03:32:48.926 SEVERE [Forwarding newSession on session null to remote] org.openqa.selenium.os.OsProcess.checkForError org.apache.commons.exec.ExecuteException: Process exited with an error: 126 (Exit value: 126)

...implies that your program was unable to execute the chromedriver binary so a null session was forwarded to the RemoteWebServer.


A bit of more information regarding the version of the ChromeDriver and ChromeBrowser would have helped us to debug your issue in a better way. However, you need to take care of a couple of facts as follows:


Solution

  • Upgrade JDK to recent levels JDK 8u201.
  • Upgrade Selenium to current levels Version 3.141.59.
  • Upgrade ChromeDriver to current ChromeDriver v2.46 level.
  • Keep Chrome version between Chrome v71-73 levels. (as per ChromeDriver v2.46 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Ensure that ChromeDriver is present in the specified location.
  • Ensure that ChromeDriver is having executable permission for non-root users.
  • Take a System Reboot.
  • Execute your @Test as a non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

trivia

You can find a couple of relevant discussion in:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=151591&siteId=1