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();
    }
5
  • 2
    It's strange, I don't even see a call to log method in your code. Can you paste full stack trace? Commented Oct 13, 2018 at 21:03
  • 5
    You need to use matched versions of poi and poi-ooxml (eg 4.0.0 for both) Commented Oct 13, 2018 at 23:43
  • 1
    At what line of the code are you getting the error Commented Oct 14, 2018 at 0: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 minimal reproducible example ). Feel free to drop me a comment in case you have further questions or feedback for me. Commented Oct 15, 2018 at 6:52
  • this answer may help your,try it! stackoverflow.com/questions/18231134/… Commented Oct 15, 2020 at 12:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.