title: Cucumber with Selenium and Junit gives : java.lang.ExceptionInInitializerError
body: <p>I'm trying to run a cucumber test using selenium / java. Based on the console output , I can say for sure that the step definiton file has been found by the feature file , but still , the moment the code enters the @Given block , it errors out with below. I tried my best to know why this error occurs , tried adding xstream jar and many other things , but just cant figure out the exact jar file that I need to add / remove or update.</p>
  <p>My Feature File is Below:</p>
  <pre><code>#Author: your.email@your.domain.com
  #Keywords Summary :
  #Feature: List of scenarios.
  #Scenario: Business rule through list of steps with arguments.
  #Given: Some precondition step
  #When: Some key actions
  #Then: To observe outcomes or validation
  #And,But: To enumerate more Given,When,Then steps
  #Scenario Outline: List of steps for data-driven as an Examples and &lt;placeholder&gt;
  #Examples: Container for s table
  #Background: List of steps run before each of the scenarios
  #&quot;&quot;&quot; (Doc Strings)
  #| (Data Tables)
  #@ (Tags/Labels):To group Scenarios
  #&lt;&gt; (placeholder)
  #&quot;&quot;
  ## (Comments)
  #Sample Feature Definition Template
  Feature: Title of your feature
    I want to use this template for my feature file
  
    Scenario: Launch the Browser
      Given I initialize the driver
      When I launch the url
      Then I land on the page
  </code></pre>
  <p>Console Output Below:</p>
  <pre><code>Feature: Title of your feature
    I want to use this template for my feature file
  
    Scenario: Launch the Browser    # src/features/browser.feature:22
      Given I initialize the driver # browser.i_initialize_the_driver()
        java.lang.ExceptionInInitializerError
      at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
      at cucumber.deps.com.thoughtworks.xstream.XStream.&lt;init&gt;(XStream.java:574)
      at cucumber.deps.com.thoughtworks.xstream.XStream.&lt;init&gt;(XStream.java:530)
      at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.&lt;init&gt;(LocalizedXStreams.java:76)
      at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
      at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
      at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
      at cucumber.api.TestStep.executeStep(TestStep.java:102)
      at cucumber.api.TestStep.run(TestStep.java:83)
      at cucumber.api.TestCase.run(TestCase.java:58)
      at cucumber.runner.Runner.runPickle(Runner.java:80)
      at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
      at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
      at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
      at cucumber.api.junit.Cucumber.runChild(Cucumber.java:117)
      at cucumber.api.junit.Cucumber.runChild(Cucumber.java:55)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:126)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
      at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
      at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
      at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
      at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
      at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
      at ?.I initialize the driver(src/features/browser.feature:23)
  Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not &quot;opens java.util&quot; to unnamed module @43bd930a
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
      at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
      at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
      at cucumber.deps.com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
      at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.&lt;clinit&gt;(TreeMapConverter.java:50)
      at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
      at cucumber.deps.com.thoughtworks.xstream.XStream.&lt;init&gt;(XStream.java:574)
      at cucumber.deps.com.thoughtworks.xstream.XStream.&lt;init&gt;(XStream.java:530)
      at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.&lt;init&gt;(LocalizedXStreams.java:76)
      at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
      at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
      at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
      at cucumber.api.TestStep.executeStep(TestStep.java:102)
      at cucumber.api.TestStep.run(TestStep.java:83)
      at cucumber.api.TestCase.run(TestCase.java:58)
      at cucumber.runner.Runner.runPickle(Runner.java:80)
      at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
      at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
      at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
      at cucumber.api.junit.Cucumber.runChild(Cucumber.java:117)
      at cucumber.api.junit.Cucumber.runChild(Cucumber.java:55)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:126)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
      at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
      at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
      at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
      at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
      at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
      at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
  
      When I launch the url         # browser.i_launch_the_url()
      Then I land on the page       # browser.i_land_on_the_page()
  </code></pre>
  <p>My Code Structure:</p>
  <p><a href="https://i.stack.imgur.com/ko5Ym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ko5Ym.png" alt="enter image description here" /></a></p>
  <p>My Test Runner Class is below:</p>
  <pre><code>package cucumbertest;
  
  import org.junit.runner.RunWith;
  
  import cucumber.api.CucumberOptions;
  import cucumber.api.junit.Cucumber;
  
  @RunWith(Cucumber.class)
  @CucumberOptions(
          
          features=&quot;src/features&quot;,
          glue=&quot;stepdefinition&quot;,
          plugin= {&quot;pretty&quot;,&quot;html:target/Cucumber.html&quot;},
          monochrome=true
          
          )
  
  
  public class TestRunner {
  
  }
  </code></pre>
  <p>My Step Definition Class is below:</p>
  <pre><code>package stepdefinition;
  
  import org.junit.Assert;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  
  import cucumber.api.java.en.Given;
  import cucumber.api.java.en.Then;
  import cucumber.api.java.en.When;
  
  public class browser {
      
      WebDriver driver;
      @Given(&quot;^I initialize the driver$&quot;)
      public void i_initialize_the_driver() throws Exception {
          // Write code here that turns the phrase above into concrete actions
          //throw new PendingException();
          System.setProperty(&quot;webdriver.gecko.driver&quot;, &quot;C:\\Users\\ttmanner\\Downloads\\geckodriver-v0.29.1-win64\\geckodriver.exe&quot;);
          driver = new FirefoxDriver();
          System.out.println(&quot;Iam in Given&quot;);
          
      }
  
      @When(&quot;^I launch the url$&quot;)
      public void i_launch_the_url() throws Exception {
          // Write code here that turns the phrase above into concrete actions
          //throw new PendingException();
          driver.get(&quot;http://idrw.org/&quot;);
      }
  
      @Then(&quot;^I land on the page$&quot;)
      public void i_land_on_the_page() throws Exception {
          // Write code here that turns the phrase above into concrete actions
          //throw new PendingException();
          
          Assert.assertTrue(driver.getTitle().equals(&quot;Defence&quot;));
      }
  
      
      
  
  }
  </code></pre>
  <p>My Jar Files are below (Not using Maven , Unfortunately I'm in a specific scenario where I cant use Maven)</p>
  <p><a href="https://i.stack.imgur.com/Ol7BV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ol7BV.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/CzYyM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CzYyM.png" alt="enter image description here" /></a></p>