Selenide / Jenkins: java.lang.IllegalStateException: No webdriver is bound to current thread:
01:16 09 Jul 2019

I have some tests written in Selenide/Java. Also I have local Jenkins on my Windows, tests are running under this Jenkins perfectly, but i have problem with tests from same repository running on external Jenkins (Linux)

Logs from Jenkins:

[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running [1mTests[m
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
1491 [main] INFO com.github.javafaker.Faker - Using default locale en
Jul 08, 2019 2:36:49 PM com.codeborne.selenide.drivercommands.LazyDriver getAndCheckWebDriver
INFO: No webdriver is bound to current thread: 1 - let's create a new webdriver
Jul 08, 2019 2:36:49 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
2687 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
3700 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Latest version of chromedriver is 76.0.3809.25
3704 [main] INFO io.github.bonigarcia.wdm.Downloader - Downloading https://chromedriver.storage.googleapis.com/76.0.3809.25/chromedriver_linux64.zip
4066 [main] INFO io.github.bonigarcia.wdm.Downloader - Extracting binary from compressed file chromedriver_linux64.zip
4194 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /var/lib/jenkins/.m2/repository/webdriver/chromedriver/linux64/76.0.3809.25/chromedriver
Starting ChromeDriver 76.0.3809.25 (a0c95f440512e06df1c9c206f2d79cc20be18bb1-refs/branch-heads/3809@{#271}) on port 28990
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jul 08, 2019 2:36:52 PM com.codeborne.selenide.drivercommands.LazyDriver getAndCheckWebDriver
INFO: No webdriver is bound to current thread: 1 - let's create a new webdriver
Starting ChromeDriver 76.0.3809.25 (a0c95f440512e06df1c9c206f2d79cc20be18bb1-refs/branch-heads/3809@{#271}) on port 30572
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[ERROR] [1;31mTests [0;1mrun: [0;1m3[m, [1;31mFailures: [0;1;31m3[m, Errors: 0, Skipped: 0, Time elapsed: 5.878 s[1;31m <<< FAILURE![m - in [1mTests[m
[ERROR] test001_logowanie_programs(Tests)  Time elapsed: 3.105 s  <<< FAILURE!
java.lang.IllegalStateException: No webdriver is bound to current thread: 1. You need to call open(url) first.
	at Tests.test001_logowanie_programs(Tests.java:38)

[ERROR] test002_logowanie_evaluation(Tests)  Time elapsed: 0.058 s  <<< FAILURE!
java.lang.IllegalStateException: No webdriver is bound to current thread: 1. You need to call open(url) first.
	at Tests.test002_logowanie_evaluation(Tests.java:50)

[ERROR] test003_fail(Tests)  Time elapsed: 0.159 s  <<< FAILURE!
java.lang.IllegalStateException: No webdriver is bound to current thread: 1. You need to call open(url) first.
	at Tests.test003_fail(Tests.java:67)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] [1;31mFailures: [m
[ERROR] [1;31m  Tests.test001_logowanie_programs:38 » IllegalState No webdriver is bound to cu...[m
[ERROR] [1;31m  Tests.test002_logowanie_evaluation:50 » IllegalState No webdriver is bound to ...[m
[ERROR] [1;31m  Tests.test003_fail:67 » IllegalState No webdriver is bound to current thread: ...[m
[INFO] 
[ERROR] [1;31mTests run: 3, Failures: 3, Errors: 0, Skipped: 0[m
[INFO] 
[ERROR] There are test failures.

Please refer to /var/lib/jenkins/jobs/nawa_selenide/workspace/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.071 s
[INFO] Finished at: 2019-07-08T14:36:56+02:00
[INFO] Final Memory: 31M/330M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/jobs/nawa_selenide/workspace/pom.xml to com/nawa/1.0-SNAPSHOT/nawa-1.0-SNAPSHOT.pom
channel stopped
Finished: UNSTABLE

On every test we have: java.lang.IllegalStateException: No webdriver is bound to current thread: Do You have experience with similar situation? Why on local machine tests are done correctly, but on main Jenkins in company there are only failures caused by No webdriver is bound to current thread? Only operating system is difference. This is problem with jenkins configuration under Linux? When I run the tests locally, using Jenkins (with Maven), I get the same message, but the WebDriver is actually created and runs my test cases. My maven goals are: mvn clean test -Puat

Declaration of Chrome in tests:

    @BeforeClass
public void setUp() throws Exception {
    Configuration.holdBrowserOpen = false;
    Configuration.browser = "chrome";
    Configuration.timeout = 10000;
    Configuration.headless = true;
    SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true).savePageSource(true));
    objReader.environmentPropertiesLoader();
}

_______________edit Now i check Start Xvfb before the build, and shut it down after in Jenkins job Build Environment, i read that is very important, maybe xvfb is the cause, i dont know, now in console i have

java.io.IOException: Cannot run program "Xvfb": error=2, No such file or directory
jenkins selenide