Running 7.3 from Java 1.8 (52) with -testjar and -xmlpathinjar throws UnsupportedClassVersionError

16 views
Skip to first unread message

Bruce Ritter

unread,
Nov 14, 2022, 5:56:17 PM11/14/22
to testng-users
We are still running Java 1.8 for testing. When I try to run TestNG from a fat jar that includes the testng .xml profile files with -testjar and -xmlpathinjar I get:

Exception in thread "main" java.lang.UnsupportedClassVersionError: module-info has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
       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 org.testng.internal.ClassHelper.forName(ClassHelper.java:80)
        at org.testng.xml.XmlClass.loadClass(XmlClass.java:72)
        at org.testng.xml.XmlClass.init(XmlClass.java:67)
        at org.testng.xml.XmlClass.init(XmlClass.java:58)
        at org.testng.xml.XmlClass.<init>(XmlClass.java:34)
        at org.testng.xml.internal.XmlSuiteUtils.constructXmlClassesUsing(XmlSuiteUtils.java:75)
        at org.testng.xml.internal.XmlSuiteUtils.newXmlSuiteUsing(XmlSuiteUtils.java:48)
        at org.testng.JarFileUtils.extractSuitesFrom(JarFileUtils.java:58)
        at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:403)
        at org.testng.TestNG.initializeEverything(TestNG.java:1017)
        at org.testng.TestNG.run(TestNG.java:1029)
        at org.testng.TestNG.privateMain(TestNG.java:1371)
        at org.testng.TestNG.main(TestNG.java:1335)

Everything appears to be 1.8, that is what is running locally (build and execution are running on the same machine), and all the Poms refer to 1.8 as the source and target versions.

Krishnan Mahadevan

unread,
Nov 14, 2022, 8:09:42 PM11/14/22
to testng...@googlegroups.com
Please take a closer look at your dependencies. I think somewhere you are bringing in TestNG 7.6.1 which is what needs JDK11. 

Until 7.5 TestNG needs JDK8. 

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

From: testng...@googlegroups.com <testng...@googlegroups.com> on behalf of Bruce Ritter <brucer...@gmail.com>
Sent: Tuesday, November 15, 2022 4:26:17 AM
To: testng-users <testng...@googlegroups.com>
Subject: [testng-users] Running 7.3 from Java 1.8 (52) with -testjar and -xmlpathinjar throws UnsupportedClassVersionError
 
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/b79f308a-e9dc-45ef-8f81-b152a270b9ddn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages