This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Maven Junit does not run on code change java.lang.UnsupportedClassVersionError t : Unsupported major.minor version 51.0 | ||
---|---|---|---|
Product: | projects | Reporter: | mohan_82 |
Component: | Maven | Assignee: | Jesse Glick <jglick> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | joshualbailey |
Priority: | P1 | ||
Version: | 7.0.1 | ||
Hardware: | PC | ||
OS: | Windows 7 x64 | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
mohan_82
2011-05-17 06:52:02 UTC
Jesse, could you please take a look. Looks like some problem in maven project configuration. Thanks! I cannot diagnose the issue without steps to reproduce it from scratch. Possibly a project misconfiguration. It seems you are running the IDE itself on JDK 6 so somewhere you must be referring to JDK 7. http://jira.codehaus.org/browse/SUREFIRE-447 is similar. Be sure to specify the source and target level in maven-compiler-plugin configuration. I'm having the same issue with 7.0.1, so I purged my machine of anything related to Java, made sure nothing was pointing to 1.7 in the xml or project files, restarted, and installed a fresh JDK 1.6.0_26 executable, but it does not fix the problem. It occurs when I run JUnit tests in the IDE. cd C:\Users\user\Documents\NetBeansProjects\Platform\sites; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_26" "\"C:\\Program Files\\NetBeans 7.0.1\\java\\maven\\bin\\mvn.bat\"" test Scanning for projects... ------------------------------------------------------------------------ Building Sites 00.01.01-SNAPSHOT ------------------------------------------------------------------------ [resources:resources] Using 'UTF-8' encoding to copy filtered resources. Copying 0 resource [compiler:compile] Compiling 3 source files to C:\Users\user\Documents\NetBeansProjects\Platform\sites\target\classes [resources:testResources] Using 'UTF-8' encoding to copy filtered resources. Copying 0 resource [compiler:testCompile] Nothing to compile - all classes are up to date [surefire:test] Surefire report directory: C:\Users\user\Documents\NetBeansProjects\Platform\sites\target\surefire-reports java.lang.reflect.UndeclaredThrowableException at $Proxy0.invoke(Unknown Source) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103) ... 4 more Caused by: java.lang.UnsupportedClassVersionError: com/thebookgrove/sites/AlibrisTest : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:105) at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78) at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:164) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:86) ... 9 more ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 8.308s Finished at: Thu Sep 15 11:53:02 MST 2011 Final Memory: 15M/173M ------------------------------------------------------------------------ Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project sites: There are test failures. Please refer to C:\Users\user\Documents\NetBeansProjects\Platform\sites\target\surefire-reports for the individual test results. -> [Help 1] To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging. For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException Hi Joshua, I managed to find why I was getting, st : Unsupported major.minor version 51.0 java.lang.UnsupportedClassVersionError: com/creative/finance/equities/daoimpl/StockSymbolInfoDaoImplTest : Unsupported major.minor version 51.0 The issue was Netbeans maven plugin could not understand properties in my maven compiler plugin. ie In my Maven compiler plugin configuration, I was setting, <src>{$java.version}</src><target>{$java.version}</target>. This configuration is not propagated to Netbeans platform project.properties. Change you pom.xml to <src>1.6</src><target>1.6</target> build and try running your test it should be fine. I have raised separate issue for that, for your info http://netbeans.org/bugzilla/show_bug.cgi?id=201938 Regards, Mohan Thanks for responding! I'm using: Product Version: NetBeans IDE 7.0.1 (Build 201107282000) Java: 1.6.0_26; Java HotSpot(TM) 64-Bit Server VM 20.1-b02 System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb) I tried setting 1.6 explicitly as you mentioned, but this still did not fix the problem. However, I did finally find the culprit... If you right click on the project -> Properties -> Build -> Compile, set "Compile on Save" to Disable, it's fixed! Mine was set to "For test execution only." for some reason, which explains why I was able to Run and Debug just fine, but could not run Unit tests... I tried this while using the ${java.version} variable for <source> and <target> and it works! (In reply to comment #5) > If you right click on the project -> Properties -> Build -> Compile, set > "Compile on Save" to Disable, it's fixed! Mine was set to "For test execution > only." for some reason That is the default, since it is faster (avoids running Maven during the edit-test cycle). For unusual project setups you can disable CoS. Bug #201938 sounds like the root issue - the IDE did not interpolate your source level, so the IDE-compiled classes used -source 7 (and implicitly -target 7) whereas the actual test run used the project's configured JDK 6. *** This bug has been marked as a duplicate of bug 201938 *** |