0

I have a Selenium/Java program that runs, sleeps for 15 minutes and then run again (All this is from within Java, I am not using cron or similar. In other words, my program always stays open. This is just a hack.)

The computer I run this on had a brief network problem and after that the following stack trace was generated

1604945147412   Marionette  INFO    Stopped listening on port 49990
1604946047821   mozrunner::runner   INFO    Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/var/folders/21/htmxfgcx7v14bbt2nr6v7ms40000gn/T/rust_mozprofile.1KxcETWwVjqE"
Exception in thread "main" org.openqa.selenium.WebDriverException: invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '15.local', ip: '2002:c3bd:1b0a:0:9981:5f04:7c52:f5f7', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
    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:422)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at kameo.KameoBid.main(MyApp.java:23)

Line 23:

WebDriver driver = new FirefoxDriver();

The program had been running fine for 20 hours (that is, it runs for 10 seconds, then Thread.sleep(1000*60*15) followed by a loop while (true)) when this happened. In other words, it runs fine and stable.

I have seen a couple of other questions with the same error message but the problem in those cases the problem seems to be an incompatibility between geckodriver and Firefox and the problem occurs immediatly, on the first run (I perform a driver.close(); just before my 15 minutes sleep).

An "unused" Firefox was left open when I discovered this problem. Don't know if that is significant.

Any ideas?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
d-b
  • 695
  • 3
  • 14
  • 43

1 Answers1

0

This error message...

Exception in thread "main" org.openqa.selenium.WebDriverException: invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '15.local', ip: '2002:c3bd:1b0a:0:9981:5f04:7c52:f5f7', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. Firefox Browser session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Though your Selenium Client version is the recent one i.e. v3.141.59
  • Your JDK version is 1.8.0_60 which is pretty old and ancient.

So there is a clear mismatch between the JDK v8u60 and Selenium Client v3.141.59.


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u261.
  • 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.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you. I am not running my program as root (What makes you think I do?). I have updated my JRE now. Isn't `tearDown` connected to JUnit? I am not running a test, I am automating a task. Should I still use `tearDown()`? – d-b Nov 09 '20 at 20:48
  • @d-b Execution of the script as a _non-root user_ and `tearDown()` are generic terms. If you aren't effected by those factors you can safely ignore those. – undetected Selenium Nov 09 '20 at 20:50