0

I am getting the below error while reading data from the excel (Ms office excel 2007) file. I m working with selenium using testNG framework.

java.lang.NoSuchMethodError: 
org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V

The POI jars i am using are as below:

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>

and below is the code i have written:

    try {
        FileInputStream fin = new FileInputStream("E:/Automation/My 
        Study/Test Data.xlsx");

        System.out.println(Runtime.class.getPackage(). 
        getImplementationVersion());
        workbook = new XSSFWorkbook(fin);
        sheet = workbook.getSheet(sheetName);
        outerHM= new HashMap<String, HashMap<String, String>>();
        innerHM= new HashMap<String, String>();
        int lastRow = sheet.getLastRowNum();

        for(int i=1; i<=lastRow; i++) {
        int lastCell = sheet.getRow(i).getLastCellNum();
            for(int j=1; j<=lastCell; j++) {
                innerHM.put(sheet.getRow(0).getCell(j).getStringCellValue(), 
                sheet.getRow(i).getCell(j).getStringCellValue());

            }
            System.out.println("Printing "+ innerHM);
            outerHM.put(sheet.getRow(i).getCell(0).getStringCellValue(), 
            innerHM);
        }

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • 2
    It's strange, I don't even see a call to log method in your code. Can you paste full stack trace? – Paras Oct 13 '18 at 21:03
  • 5
    You need to use matched versions of poi and poi-ooxml (eg 4.0.0 for both) – PJ Fanning Oct 13 '18 at 23:43
  • 1
    At what line of the code are you getting the error – Alok Oct 14 '18 at 00:54
  • Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. But I think your question is still not answerable. **You** should [edit] your question now, to add missing details (see [mcve] ). Feel free to drop me a comment in case you have further questions or feedback for me. – GhostCat Oct 15 '18 at 06:52
  • this answer may help your,try it! https://stackoverflow.com/questions/18231134/how-to-avoid-java-lang-nosuchmethoderror-org-apache-poi-util-ioutils-copyljava – shangjiuliu Oct 15 '20 at 12:14

0 Answers0