gradle/gradle · error · UnsupportedOperationException
Could not locate any of these interfaces: 'org.testng.IConfi
Error message
Could not locate any of these interfaces: 'org.testng.IConfigurationListener', 'org.testng.IConfigurationListener2', 'org.testng.internal.IConfigurationListener'. Which version of TestNG are you using?
What it means
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.
Source
Thrown at platforms/jvm/testing-jvm-infrastructure/src/main/java/org/gradle/api/internal/tasks/testing/testng/TestNGListenerAdapterFactory.java:53
}
public ITestListener createAdapter(ITestListener listener) {
Class<?> testNG7Class = tryLoadClass("org.testng.IConfigurationListener");
if (testNG7Class != null) {
return createProxy(testNG7Class, listener);
}
Class<?> testNG6Class = tryLoadClass("org.testng.IConfigurationListener2");
if (testNG6Class != null) {
return createProxy(testNG6Class, listener);
}
Class<?> testNG5Class = tryLoadClass("org.testng.internal.IConfigurationListener");
if (testNG5Class != null) {
return createProxy(testNG5Class, listener);
}
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?");
}
private Class<?> tryLoadClass(String name) {
try {
return classLoader.loadClass(name);
} catch (ClassNotFoundException e) {
return null;
}
}
private ITestListener createProxy(Class<?> configListenerClass, final ITestListener listener) {
List<Class<?>> interfaces = new ArrayList<Class<?>>();
interfaces.add(ITestListener.class);
interfaces.add(ISuiteListener.class);
interfaces.add(configListenerClass);
Class<?> iClassListenerClass = tryLoadClass("org.testng.IClassListener");
View on GitHub (pinned to 534f27719b)
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
Example fix
// before
dependencies {
testImplementation 'org.testng:testng:5.5'
}
// after
dependencies {
testImplementation 'org.testng:testng:7.10.2'
} Defensive patterns
Strategy: validation
Validate before calling
// require a TestNG new enough for the adapter interfaces
test {
doFirst {
def urls = sourceSets.test.runtimeClasspath.files.collect { it.toURI().toURL() } as URL[]
def cl = new URLClassLoader(urls, null)
assert cl.findResource('org/testng/IConfigurationListener2.class') != null : \
'TestNG on the classpath is too old/broken for Gradle - upgrade org.testng:testng'
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Legacy builds pinned to TestNG 5.x; fat/shaded jars relocating org.testng classes; corrupted artifacts from an internal repository.
Related errors
- Could not load %s.
- The version of TestNG used does not support setting config f
- Can't load category class [%s].
- Unable to process Ignored class %s.
- Failed to execute test class: '%s'.
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/9cebcf826f1868ec.
Report an issue: GitHub.