Selenium Webdriver Java - Eclipse java lang NoClassDefFoundError

+2 votes

I have installed java and eclipse, and downloaded the JARS and placed them in the right directory as it should be. Below is my script:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class myClass {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Hello\n");

        System.setProperty("webdriver.chrome.driver", "C:/Selenium/Drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.facebook.com");
    }
}

And i get the below error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/config/RegistryBuilder
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:69)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:242)
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:219)
    at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:93)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:72)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:63)
    at org.openqa.selenium.chrome.ChromeDriverCommandExecutor.<init>(ChromeDriverCommandExecutor.java:36)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at myClass.main(myClass.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.http.config.RegistryBuilder
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 13 more

This is my first script and i'm getting an error even though its basic. Can someone plz help?

Apr 14, 2018 in Selenium by kappa3010
• 2,090 points
71,519 views

I also found found the same issue. 

My code is :

package abcd;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class Admin {

public static void main(String[] args) throws InterruptedException {

//Instantiate Chrome Browser Driver

System.setProperty("webdriver.chrome.driver","C://Users//Falgu//AutomationProfile//chromedriver.exe");

//Create Chrome Browser Driver

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();

driver.get("https://www.google.com");

//driver.quit();

}

}

And got below error 

Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809@{#864}) on port 27898

Only local connections are allowed.

Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 76

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'

Driver info: driver.version: ChromeDriver

remote stacktrace: Backtrace:

Ordinal0 [0x009D7C93+1473683]

Ordinal0 [0x0095ADB1+961969]

Ordinal0 [0x008E42E3+475875]

Ordinal0 [0x0087F365+62309]

Ordinal0 [0x0087BC77+48247]

Ordinal0 [0x00899149+168265]

Ordinal0 [0x00898D1D+167197]

Ordinal0 [0x0089742B+160811]

Ordinal0 [0x00880AE6+68326]

Ordinal0 [0x00881BF0+72688]

Ordinal0 [0x00881B89+72585]

Ordinal0 [0x00974B77+1067895]

GetHandleVerifier [0x00A76875+506677]

GetHandleVerifier [0x00A76610+506064]

GetHandleVerifier [0x00A7D1B8+533624]

GetHandleVerifier [0x00A7704A+508682]

Ordinal0 [0x0096C266+1032806]

Ordinal0 [0x0096C0DF+1032415]

Ordinal0 [0x00976A8B+1075851]

Ordinal0 [0x00976BF3+1076211]

Ordinal0 [0x00975BA5+1072037]

BaseThreadInitThunk [0x74C433CA+18]

RtlInitializeExceptionChain [0x77449ED2+99]

RtlInitializeExceptionChain [0x77449EA5+54]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

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(Unknown Source)

at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)

at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)

at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)

at java.util.stream.AbstractPipeline.copyInto(Unknown Source)

at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)

at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)

at java.util.stream.AbstractPipeline.evaluate(Unknown Source)

at java.util.stream.ReferencePipeline.findFirst(Unknown Source)

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.chrome.ChromeDriver.<init>(ChromeDriver.java:181)

at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)

at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)

at abcd.Admin.main(Admin.java:12)

- I have added Jar files as well. and followed the steps which mentioned by king_kenny . But still facing the issue.

Please someone help me.

Hey there, you can first check which version of ChromeDriver is supported by Chrome Browser. You can simple google which version of ChromeDriver is supported by Chrome Browser version-76.

Then you can delete previously installed ChromeDriver.exe file and install the supported version.
Thank you so much. it is working. :)
Good to hear that. You can also post any other queries you have, here on Community.
Где Вы ищите свежие новости?
Лично я читаю и доверяю газете https://www.ukr.net/.
Это единственный источник свежих и независимых новостей.
Рекомендую и Вам

3 answers to this question.

+5 votes
Best answer

I also faced this issue first time, in order to solve this I checked build path configured for my project.There you will see two options 1. Module path 2. Class path

Add your all external jars such as selenium jars under class path not module path and retry. It worked for me and If you need to know more, join our Selenium Training Online.

answered Aug 28, 2019 by Shraddha

selected Dec 9, 2019 by Kalgi
Hi Shraddha, thank you for sharing your solution.
It helped. Thankyou
You're welcome. You can also post your issues/queries on this community.
Thanks a bunch, It worked like charm for me too.

Thanks again
Glad it worked for you!!!
Thank u so much.It helped me alot
Thanks a ton.

I have been searching for this for a couple of hours!

Thanks a lot...i was struggling with this issue. it worked for me. Thanks again.

You're welcome nyan. You can post any other questions if you have on Selenium.
Thank you soooooooooooooooooooooo much. I was facing this issue from a long time and searched in so many websites. All are telling blah blah blah.Now I tried this and it worked for me.Thank you again.
Hey! Please do register at Edureka Community and upvote the answer if it has helped you :)
Thanks!This worked for me as well.:-)
Using given solution same problem has been fixed thanks...
This worked for me as well. I removed all the jars from the "Module Path" and added again to the "Class Path" and ran the first test of the launching Chrome successfully. Thanks- Shraddha
Thanks it worked
Thanks, @Kuntal for your contribution.

Please register at Edureka Community and earn credits for every contribution. A contribution could be asking a question, answering, commenting or even upvoting/downvoting an answer or question.

These credits can be used to get a discount on the course. Also, you could become the admin at Edureka Community with certain points.

Cheers!
Thank You so much !. The Same Issue Has Came To Me Also. You Answer Has Gave me a Solution To My Issue.

As you can see i dont have 1. Module path 2. Class path what can be done in my case as i am receiveing same error 

Error: Unable to initialize main class Demo
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

Have you added the Selenium Standalone JAR to your Java Project in Eclipse?
Thank you so much! I wasted 4 hours in solving this and you saved my day.
Glad to help! Do upvote the answer in case you found it helpful :)
Hi,

 Where can I get the Module path and build path in the above said window.
You need to right-click on your project's name and go to "build path" in your eclipse IDE.
I am getting this below error even after adding required standalone and other jar files. Can you please help to solve this error.

****************************************************************************************************************************
ERROR:

[TestNG] Running:

  C:\Users\Manav\AppData\Local\Temp\testng-eclipse-1341838548\testng-customsuite.xml

FAILED: LoginI

java.lang.NoClassDefFoundError: javax/crypto/SecretKey

at sun.security.util.KeyUtil.getKeySize(KeyUtil.java:79)

at sun.security.util.DisabledAlgorithmConstraints$KeySizeConstraint.permitsImpl(DisabledAlgorithmConstraints.java:869)

at sun.security.util.DisabledAlgorithmConstraints$KeySizeConstraint.permits(DisabledAlgorithmConstraints.java:836)

at sun.security.util.DisabledAlgorithmConstraints$Constraints.permits(DisabledAlgorithmConstraints.java:357)

at sun.security.util.DisabledAlgorithmConstraints.checkConstraints(DisabledAlgorithmConstraints.java:203)

at sun.security.util.DisabledAlgorithmConstraints.permits(DisabledAlgorithmConstraints.java:127)

at sun.security.pkcs.SignerInfo.verify(SignerInfo.java:405)

at sun.security.pkcs.PKCS7.verify(PKCS7.java:579)

at sun.security.pkcs.PKCS7.verify(PKCS7.java:596)

at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:287)

at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)

at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)

at java.util.jar.JarVerifier.update(JarVerifier.java:230)

at java.util.jar.JarFile.initializeVerifier(JarFile.java:384)

at java.util.jar.JarFile.ensureInitialization(JarFile.java:615)

at java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)

at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:991)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)

at java.net.URLClassLoader.access$100(URLClassLoader.java:74)

at java.net.URLClassLoader$1.run(URLClassLoader.java:369)

at java.net.URLClassLoader$1.run(URLClassLoader.java:363)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:362)

at java.lang.ClassLoader.loadClass(ClassLoader.java:418)

at java.lang.ClassLoader.loadClass(ClassLoader.java:405)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)

at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:215)

at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206)

at java.security.AccessController.doPrivileged(Native Method)

javax.crypto package is included in jce.jar, which can be found under the "lib" folder of your JRE. Add it to your classpath, and you should be fine.

For more information about classpath, see: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

Thanks alot for help, it worked :D:D
Thanks a alot for help after trying for 2 hrs finaly i got it.
How to change that Brother can you tell the procedure plzzzz
0 votes

java.lang.NoClassDefFoundError is usually thrown when the installed JRE cannot find the Class which needs to be executed.

Also, the required imports and JARS would also not be available. It seems like you have tried to add the jars related to Java Client. So the only solution is to remove and place all the JARS again correctly.
Do th following:

  1. Remove all JARS including Selenium standalone server & Selenium Java client
  2. Import all the JARS which you downloaded from here: https://www.seleniumhq.org/download/.
  3. Make sure to import them to "Add External JARS" from "Conigure Build Path" option in Eclipse IDE.

This has to definately work.

answered Apr 14, 2018 by king_kenny
• 3,710 points
0 votes
can you the path like this way - C:\\Users\\Desktop\\SELENIUM\\chromedriver.exe
answered Feb 23, 2019 by anonymous
Yes, that's correct by the help of escaping character the error can be solved.

Related Questions In Selenium

0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,090 points
4,747 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,302 views
+1 vote
3 answers

java.lang.ClassNotFoundException: okhttp3.ConnectionPool - Selenium Error

The only reason for ClassNotFoundException is if ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,500 points
18,511 views
+1 vote
1 answer

How to perform mouse hovering in Selenium WebDriver (Java)?

You many not actually be able to ...READ MORE

answered Apr 3, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 22, 2023 by Khan Sarfaraz 10,720 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,868 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,567 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,084 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,178 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,840 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP