title: chromedriver: cannot execute binary file and SEVERE Forwarding newSession on session null to remote with ChromeDriver Selenium through Java
body: <p>I have a service that is using selenium to start a chrome webdriver using chrome <code>headless</code> mode. The application is launched through <code>tomcat8</code>. I can run the service without issue locally on my mac.</p>
  
  <p>But once I deployed it to ec2 node through <code>AWS Elastic Beanstalk</code>, the webdriver cannot start properly:</p>
  
  <pre><code>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.&lt;init&gt;(RemoteWebDriver.java:142)
      at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:181)
      at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:168)
      at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:157)
      at com.christina.insbot.factory.BrowserDriverFactory.createWebDriver(BrowserDriverFactory.java:64)
      at com.christina.insbot.service.InsBot.&lt;init&gt;(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
  </code></pre>
  
  <p>CATALINA error:</p>
  
  <pre><code>/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)
  </code></pre>
  
  <p>The way I start the webdriver is like this:</p>
  
  <pre><code>        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);
  </code></pre>