'How to add listeners class in testng.xml?

I got the error message as shown below as I was trying to add listeners class in testng.xml, I will be really grateful if you could give me a clue. Thanks a million! error message:

The content of element type "suite" must match "(groups?,(listeners|packages|test|parameter|method-selectors|suite-files)*)".

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
    <listerners>
        <listerner class-name="Academy.listeners"/>
    </listerners>
</suite>

listener class:

import java.io.IOException;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;

import resources.DriverBase;

public class listeners implements ITestListener {

    DriverBase db = new DriverBase();

    public void onTestFailure(ITestResult result) {
        // TODO Auto-generated method stub
        try {
            db.getScreenshot();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}


Solution 1:[1]

You have a typo in your testng xml file. You have misspelt listeners as listerners

Please change

<listerners>
     <listerner class-name="Academy.listeners"/>
</listerners> 

To

<listeners>
     <listener class-name="Academy.listeners"/>
</listeners> 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krishnan Mahadevan