title: Cannot Instantiate Class Exception TestNG
body: <p><strong>I am facing this 'Cannot instantiate class' error on running one of my test case in selenium webdriver using java with TestNG. I am trying to use parameterization in selenium webdriver using excel.</strong></p>
  
  <p><strong>Below is the class of the functionality of the test</strong></p>
  
  <pre><code>package parameterizationExcel;
  
  import org.testng.annotations.Test;
  
  import jxl.Sheet;
  import jxl.Workbook;
  import jxl.read.biff.BiffException;
  
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.DataProvider;
  
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  import org.testng.Assert;
  import org.testng.annotations.AfterTest;
  
  public class ReadExcelDataProvider {
  
  public WebDriver driver;
  public WebDriverWait myWaitVar = new WebDriverWait(driver, 30);
  
  //Locators
  private By byPickupLoc = By.id("pickupLoc");
  //private By byPassword = By.id("session_password-login");
  private By bySearch = By.cssSelector("div.ui.blue.large.submit.button.ng-isolate-scope");
  private By byError = By.cssSelector("div.ui.error.message");
  
    @BeforeTest
    public void beforeTest() {
  
        System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
          driver=new ChromeDriver();
          driver.manage().window().maximize();
    } 
  
    @Test(dataProvider="searchLocation")
    public void VerifyValidLocations(String topLocation)throws     InterruptedException {
  
    driver.get("https://carhire.vroomtest.com/");
        myWaitVar.until(ExpectedConditions.visibilityOfElementLocated(byPickupLoc));
      driver.findElement(byPickupLoc).sendKeys(topLocation);
        myWaitVar.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("strong.ng-binding")));
      driver.findElement(By.cssSelector("strong.ng-binding")).click();
  
      //wait for element to be visible and perform click
      myWaitVar.until(ExpectedConditions.visibilityOfElementLocated(bySearch));
      driver.findElement(bySearch).click();
  
      //Check for error message
      myWaitVar.until(ExpectedConditions.visibilityOfElementLocated(byError));
      String actualErrorDisplayed = driver.findElement(byError).getText();
      String requiredErrorMessage = "Please correct the marked field(s) below.";
      Assert.assertEquals(requiredErrorMessage, actualErrorDisplayed);
  
      //Results Page
      myWaitVar.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".resultsCount &gt; strong")));
    }
  
  
    @AfterTest
    public void afterTest() {
  
    driver.quit();
    }
  
     @DataProvider(name="searchLocation")
  public Object[][] searchData() {
      Object[][] arrayObject = getExcelData("E:/ODESK/VroomVroomVroom/sampledoc.xlsx","Sheet1");
      return arrayObject;
  }
  
    /**
       * @param File Name
       * @param Sheet Name
       * @return
   */
  
    public String[][] getExcelData(String fileName, String sheetName) {
      String[][] arrayExcelData = null;
      try {
          FileInputStream fs = new FileInputStream(fileName);
          Workbook wb = Workbook.getWorkbook(fs);
          Sheet sh = wb.getSheet(sheetName);
  
          int totalNoOfCols = sh.getColumns();
          int totalNoOfRows = sh.getRows();
  
          arrayExcelData = new String[totalNoOfRows-1][totalNoOfCols];
  
          for (int i= 1 ; i &lt; totalNoOfRows; i++) {
  
              for (int j=0; j &lt; totalNoOfCols; j++) {
                  arrayExcelData[i-1][j] = sh.getCell(j, i).getContents();
              }
  
          }
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
          e.printStackTrace();
      } catch (BiffException e) {
          e.printStackTrace();
      }
      return arrayExcelData;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Here is Exception I got.</strong></p>
  
  <pre><code>org.testng.TestNGException: 
  Cannot instantiate class parameterizationExcel.ReadExcelDataProvider
  at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
  at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:382)
  at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:295)
  at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:117)
  at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:183)
  at org.testng.internal.TestNGClassFinder.&lt;init&gt;(TestNGClassFinder.java:128)
  at org.testng.TestRunner.initMethods(TestRunner.java:415)
  at org.testng.TestRunner.init(TestRunner.java:241)
  at org.testng.TestRunner.init(TestRunner.java:211)
  at org.testng.TestRunner.&lt;init&gt;(TestRunner.java:165)
  at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:142)
  at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:272)
  at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:587)
  at org.testng.SuiteRunner.init(SuiteRunner.java:161)
  at org.testng.SuiteRunner.&lt;init&gt;(SuiteRunner.java:114)
  at org.testng.TestNG.createSuiteRunner(TestNG.java:1260)
  at org.testng.TestNG.createSuiteRunners(TestNG.java:1247)
  at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
  at org.testng.TestNG.run(TestNG.java:1018)
  at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
  at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
  at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
  
  Caused by: java.lang.reflect.InvocationTargetException
  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.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
  ... 21 more
  
  Caused by: java.lang.NullPointerException
  at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
  at org.openqa.selenium.support.ui.FluentWait.&lt;init&gt;(FluentWait.java:102)
  at org.openqa.selenium.support.ui.WebDriverWait.&lt;init&gt;(WebDriverWait.java:71)
  at org.openqa.selenium.support.ui.WebDriverWait.&lt;init&gt;(WebDriverWait.java:45)
  at parameterizationExcel.ReadExcelDataProvider.&lt;init&gt;(ReadExcelDataProvider.java:27)
  ... 26 more
  </code></pre>