{"record":{"id":"9cebcf826f1868ec","repo":"gradle/gradle","slug":"could-not-locate-any-of-these-interfaces-org-tes","errorCode":null,"errorMessage":"Could not locate any of these interfaces: 'org.testng.IConfigurationListener', 'org.testng.IConfigurationListener2', 'org.testng.internal.IConfigurationListener'. Which version of TestNG are you using?","messagePattern":"Could not locate any of these interfaces: 'org\\.testng\\.IConfigurationListener', 'org\\.testng\\.IConfigurationListener2', 'org\\.testng\\.internal\\.IConfigurationListener'\\. Which version of TestNG are you using\\?","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"platforms/jvm/testing-jvm-infrastructure/src/main/java/org/gradle/api/internal/tasks/testing/testng/TestNGListenerAdapterFactory.java","lineNumber":53,"sourceCode":"    }\n\n    public ITestListener createAdapter(ITestListener listener) {\n        Class<?> testNG7Class = tryLoadClass(\"org.testng.IConfigurationListener\");\n        if (testNG7Class != null) {\n            return createProxy(testNG7Class, listener);\n        }\n\n        Class<?> testNG6Class = tryLoadClass(\"org.testng.IConfigurationListener2\");\n        if (testNG6Class != null) {\n            return createProxy(testNG6Class, listener);\n        }\n\n        Class<?> testNG5Class = tryLoadClass(\"org.testng.internal.IConfigurationListener\");\n        if (testNG5Class != null) {\n            return createProxy(testNG5Class, listener);\n        }\n\n        throw new UnsupportedOperationException(\"Could not locate any of these interfaces: 'org.testng.IConfigurationListener', 'org.testng.IConfigurationListener2', 'org.testng.internal.IConfigurationListener'. Which version of TestNG are you using?\");\n    }\n\n    private Class<?> tryLoadClass(String name) {\n        try {\n            return classLoader.loadClass(name);\n        } catch (ClassNotFoundException e) {\n            return null;\n        }\n    }\n\n    private ITestListener createProxy(Class<?> configListenerClass, final ITestListener listener) {\n        List<Class<?>> interfaces = new ArrayList<Class<?>>();\n        interfaces.add(ITestListener.class);\n        interfaces.add(ISuiteListener.class);\n        interfaces.add(configListenerClass);\n\n        Class<?> iClassListenerClass = tryLoadClass(\"org.testng.IClassListener\");\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/jvm/testing-jvm-infrastructure/src/main/java/org/gradle/api/internal/tasks/testing/testng/TestNGListenerAdapterFactory.java#L35-L71","documentation":"TestNGListenerAdapterFactory adapts Gradle's ITestListener to whatever configuration-listener interface the present TestNG version exposes, trying org.testng.IConfigurationListener, org.testng.IConfigurationListener2 (TestNG 6+) and org.testng.internal.IConfigurationListener (TestNG 5) in turn. If none of the three loads, the TestNG jar is unrecognizably old, stripped or broken, and it throws UnsupportedOperationException naming the interfaces and the TestNG version question.","triggerScenarios":"useTestNG() with a TestNG artifact predating the supported interfaces, a relocated/shaded testng jar whose classes moved packages, or a corrupt testng artifact where the classes exist as resources but do not load.","commonSituations":"Legacy builds pinned to TestNG 5.x; fat/shaded jars relocating org.testng classes; corrupted artifacts from an internal repository.","solutions":["Upgrade to a modern TestNG: testImplementation 'org.testng:testng:7.10.2'","Verify the jar actually contains the interfaces: jar tf testng-*.jar | grep IConfigurationListener","Remove shading/relocation of org.testng packages from your packaging, or stop putting the relocated jar on the test classpath","If stuck on old TestNG, drop useTestNG() tooling that needs the adapter or accept JUnit for those tests"],"exampleFix":"// before\ndependencies {\n    testImplementation 'org.testng:testng:5.5'\n}\n// after\ndependencies {\n    testImplementation 'org.testng:testng:7.10.2'\n}","handlingStrategy":"validation","validationCode":"// require a TestNG new enough for the adapter interfaces\ntest {\n    doFirst {\n        def urls = sourceSets.test.runtimeClasspath.files.collect { it.toURI().toURL() } as URL[]\n        def cl = new URLClassLoader(urls, null)\n        assert cl.findResource('org/testng/IConfigurationListener2.class') != null : \\\n            'TestNG on the classpath is too old/broken for Gradle - upgrade org.testng:testng'\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin org.testng:testng to a current 7.x release with a dependency constraint","Do not put shaded/relocated testng jars on the test classpath","Verify jar contents (IConfigurationListener* entries) when pulling TestNG from internal mirrors"],"tags":["testng","gradle","version-incompatibility","listener-adapter","class-loading"],"backgroundTag":"unsupported-library-version","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}