Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError

0 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;

public class myClass {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.setProperty("", "C:/Selenium/Drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();

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(
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(
    at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(
    at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(
    at myClass.main(
Caused by: java.lang.ClassNotFoundException: org.apache.http.config.RegistryBuilder
    at 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 13, 2018 in Selenium by kappa3010
• 2,010 points

2 answers to this question.

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:
  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 13, 2018 by king_kenny
• 3,590 points
0 votes
can you the path like this way - C:\\Users\\Desktop\\SELENIUM\\chromedriver.exe
answered Feb 23 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,070 points
0 votes
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,050 points
+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,050 points
0 votes
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,050 points

edited Apr 4, 2018 by nsv999 2,311 views
0 votes
1 answer

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,050 points
0 votes
1 answer
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,130 points
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
+2 votes
1 answer

How can we handle authentication popup in Selenium WebDriver using Java

The Alert Method, authenticateUsing() lets us skip ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,590 points
+9 votes
13 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,280 points