testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

NoClassDefFoundError for class IAnnotationTransformer2 when upgrading from 6.10 to 7.1.0 #2263

Closed AutomateItEasyWay closed 4 years ago

AutomateItEasyWay commented 4 years ago

TestNG Version

7.1.0

Note: only the latest version is supported

Expected behavior

Tests that were executed when run on TestNG 6.10 should still execute on TestNG 7.1.0.

Actual behavior

As soon as I start execution of tests using testng.xml I get an exception

java.lang.NoClassDefFoundError: org/testng/IAnnotationTransformer2 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:961) at org.testng.TestNG.initializeConfiguration(TestNG.java:898) at org.testng.TestNG.initializeEverything(TestNG.java:988) at org.testng.TestNG.run(TestNG.java:999) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123) Caused by: java.lang.ClassNotFoundException: org.testng.IAnnotationTransformer2 at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 23 more

Is the issue reproductible on runner?

Note: Same tests get executed perfectly if I start with clean slate on version 7.1.0

krmahadevan commented 4 years ago

You would need to fix your project to remove references of the deprecated and then removed listener reference of IAnnotationTransformer2. This interface was removed intentionally after TestNG enabled support for JDK8. Since you are making a jump across releases that are years apart, you perhaps didn't notice those warnings on deprecation.

There's nothing to be fixed here. That interface is gone and its signature is baked into IAnnotationTransformer itself. So the fix would be to replace references of IAnnotationTransformer2 with IAnnotationTransformer

Closing this with the resolution as Working as designed