UnsupportedClassVersionError

62 views
Skip to first unread message

Thomas Fišer

unread,
Jun 29, 2011, 6:37:39 AM6/29/11
to testng-users
Hi Cedric

Back after a long time. I recently tried to run a test from the
context menu, and got this exception. It seems it tries to parse an
XML Suite file, but I didn't specify one, neither in my run config nor
in my preferences. What am I doing wrong here?

java.lang.UnsupportedClassVersionError: Bad version number in .class
file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.testng.internal.ClassHelper.forName(ClassHelper.java:95)
at org.testng.xml.XmlClass.loadClass(XmlClass.java:73)
at org.testng.xml.XmlClass.init(XmlClass.java:68)
at org.testng.xml.XmlClass.<init>(XmlClass.java:54)
at
org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:
516)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:
533)
at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:
220)
at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:
819)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:
872)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:
1693)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:
368)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
834)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
764)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:
148)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:
1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:176)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
at org.testng.xml.Parser.parse(Parser.java:170)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:299)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:90)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:203)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
RemoteTestNG finishing: 0 ms

Cédric Beust ♔

unread,
Jun 29, 2011, 1:27:10 PM6/29/11
to testng...@googlegroups.com
Hi Thomas,

Not sure what's going on here. Both TestNG and the Eclipse plug-in are compiled with Java 5. Maybe your own tests is compiled with Java 6 and you are trying to run it with Java 5?

It's also possible that I made a mistake and built with Java 6...

-- 
Cédric





--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


Thomas Fišer

unread,
Jun 30, 2011, 9:10:42 AM6/30/11
to testng-users
Hi Cedric,

All I did was I hacked the tests into the editor and did a right-click-
>run as TestNG Test on it. You might be on the right track with the
Java6. When I edited the Run Configuration the context menu entry left
me and set it to use Java6, it worked. (It was set to Java5)

On 29 Jun., 19:27, Cédric Beust ♔ <ced...@beust.com> wrote:
> Hi Thomas,
>
> Not sure what's going on here. Both TestNG and the Eclipse plug-in are
> compiled with Java 5. Maybe your own tests is compiled with Java 6 and you
> are trying to run it with Java 5?
>
> It's also possible that I made a mistake and built with Java 6...
>
> --
> Cédric
>

Cédric Beust ♔

unread,
Jun 30, 2011, 12:14:06 PM6/30/11
to testng...@googlegroups.com
One way to fix this for good would be to make sure you are launching Eclipse itself with Java 6. However, you should probably try to get to the bottom of the error you are seeing right now (and again, it's possible that I made a mistake and built either testng.jar or the Eclipse plug-in with Java 6, even though I do have checks in place to avoid this).

-- 
Cédric

Reply all
Reply to author
Forward
0 new messages