rich
rich

Reputation: 61

java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException

I am using Firefox 45.0 and Dependency added in pom.xml is selenium-firefox-driver 2.53.0.

java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
    at TestFIles_MDM.Test_Authn.setup(Test_Authn.java:27)

Error is coming for both Firefox and Chrome.

How can I resolve it, it was working last week.

Upvotes: 6

Views: 48954

Answers (5)

jack west
jack west

Reputation: 1

I ran into this too. I changed to the following and it went away.

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>4.0.0-alpha-2</version>
</dependency>


    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>6.1.0</version>
        <scope>provided</scope>
    </dependency>

Upvotes: -1

timbre timbre
timbre timbre

Reputation: 13970

I think you are missing this dependency in pom.xml:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version>
</dependency>  

Check Selenium docs about Maven dependencies.

Upvotes: 4

Chris
Chris

Reputation: 10338

Run mvn dependency:tree in your project, and check what is transitively depending on selenium-remote-driver.

In my project, I was correctly depending on selenium-java at 2.53.1, but another test dependency was depending on an older version (2.40.0); that meant my tests were using the 2.40.0 version of selenium-remote-driver at runtime, which causes the java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException error.

If you have transitive dependencies on selenium-remote-driver, you have two options for "fixing" them:

  1. Update the artifact that's depending on the older version to either
    • Not depend on the artifact at all, or
    • Use the latest version.
  2. Add an entry in your pom.xml's <dependencyManagement> section for selenium-java to peg the artifact at version 2.53.1.

    This will affect the version of selenium-java both in your project and all your nested maven dependencies, too; be aware that those nested artifacts may not work well with the latest version!

It's also worth mentioning that selenium-java version 2.53.0 had a Firefox incompatibility problem; version 2.53.1 allegedly fixes that. See http://seleniumsimplified.com/2016/06/use_selenium_webdriver_jar_locally/ for more details.

Hope this helps :)

Upvotes: 2

BS_CC
BS_CC

Reputation: 11

This happened with me while trying to update to remote driver to 3.0.1 from 2.53.1. I just reverted it back to 2.53.1 and it went away

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.1</version>
</dependency>

Upvotes: 1

Shivam
Shivam

Reputation: 199

Voila, It's worked for me.Just updated the selenium-java dependency in pom.xml

<!--  Selenium java-jar dependency -->

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>

Or here is the link to get the updated version- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

Upvotes: 2

Related Questions