0

NoClassDefFoundError while reading Excel sheet data and printing values I am getting classnotfound exception for below code :

package practice;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class dataDriven {

    public static void main(String[] args) throws FileNotFoundException,IOException
    {
        FileInputStream fis = new FileInputStream("C://Users//484834//testdata.xlsx");
        XSSFWorkbook wb = new XSSFWorkbook(fis);
        wb =null;

        int sheets = wb.getNumberOfSheets();
        System.out.println("Number of sheets is "+sheets);
    }

}

output is :

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
    at practice.dataDriven.main(dataDriven.java:14)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap
    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)
    ... 1 more
Anju
  • 1
  • 1

1 Answers1

0

It looks like you are missing the the jar file. You can add commons-collections4-x.jar in build path.

URL for the same is -https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.2

Hope this will resolve your issue.

vikash singh
  • 1,479
  • 1
  • 19
  • 29