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.
Using 6.1 with this build information: Product Version: NetBeans IDE Dev (Build 200803021202) Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119 System: Mac OS X version 10.5.2 running on i386; MacRoman; en_US (nb) Userdir: /Users/David/.netbeans/dev When I try to create a standard Java->Java Application project I get the following exception. I have tried this with a clean userdir and get the same results. Please look below the stack trace for another one that is generated when I try to report the exception from within the IDE. java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) 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:316) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:213) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at sun.misc.Service$LazyIterator.next(Service.java:271) at javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:127) at javax.script.ScriptEngineManager.access$000(ScriptEngineManager.java:55) at javax.script.ScriptEngineManager$1.run(ScriptEngineManager.java:98) at java.security.AccessController.doPrivileged(Native Method) at javax.script.ScriptEngineManager.init(ScriptEngineManager.java:96) at javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:69) at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler.engine(ScriptingCreateFromTemplateHandler.java:125) at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler.accept(ScriptingCreateFromTemplateHandler.java:67) at org.openide.loaders.MultiDataObject.handleCreateFromTemplate(MultiDataObject.java:694) at org.openide.loaders.DefaultDataObject.handleCreateFromTemplate(DefaultDataObject.java:159) at org.openide.loaders.DataObject$CreateAction.run(DataObject.java:1247) at org.openide.loaders.DataObjectPool$1WrapAtomicAction.run(DataObjectPool.java:238) at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120) at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:499) at org.openide.loaders.DataObjectPool.runAtomicAction(DataObjectPool.java:250) at org.openide.loaders.DataObject.invokeAtomicAction(DataObject.java:861) at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:793) at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:773) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createMainClass(J2SEProjectGenerator.java:368) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.access$200(J2SEProjectGenerator.java:78) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator$1.run(J2SEProjectGenerator.java:116) at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120) at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:499) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createProject(J2SEProjectGenerator.java:97) at org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator.instantiate(NewJ2SEProjectWizardIterator.java:181) at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1023) at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:595) at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:416) at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:253) at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:165) at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1384) at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1341) at org.openide.WizardDescriptor.access$1600(WizardDescriptor.java:119) at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:1908) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986) I get this exception trying to report the exception within the IDE. Looks like the URL is invalid. java.io.IOException: Server returned HTTP response code: 403 for URL: http://testwww.netbeans.org/nonav/uigestures/error.html at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1170) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367) at javax.swing.JEditorPane.getStream(JEditorPane.java:689) Caused: java.io.IOException: Server returned HTTP response code: 403 for URL: http://testwww.netbeans.org/nonav/uigestures/error.html at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1223) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1217) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:906) at javax.swing.JEditorPane.getStream(JEditorPane.java:719) at javax.swing.JEditorPane.setPage(JEditorPane.java:406) at org.netbeans.modules.uihandler.Installer$SubmitInteractive.assignInternalURL(Installer.java:1289) at org.netbeans.modules.uihandler.Installer$Submit.doShow(Installer.java:888) at org.netbeans.modules.uihandler.Installer.doDisplaySummary(Installer.java:475) at org.netbeans.modules.uihandler.Installer.displaySummary(Installer.java:410) at org.netbeans.modules.uihandler.UIHandler.run(UIHandler.java:138) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
reassigning to j2seproject. We tried to reproduce on Mac - without success
Where did you get the build? Did you download it from NB web or did you compile it yourself?
I downloaded a binary distribution copy and installed it. I also downloaded the M1 version and got the same error. Upon more investigation, I discovered the issue to be around using JDK 5. If I switch to using JDK 6 on the Mac, the error goes away. I believe this is a defect that some classes were compiled for JDK 6 since JDK 6 doesn't seem to be a system requirement.
Apple problem, I've also spent nearly a day solving it. The problem is that when you install JDK 1.6 on your Mac you actually destroy the JDK 1.5. The apple has several extension folders for java, defined by the java.ext.dirs property, here they are: /Library/Java/Extensions /System/Library/Java/Extensions /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext The installation of the JDK 1.6 puts some jars with 1.6 bytecode into /System/Library/Java/Extensions. Unfortunately this and /Library/Java/Extensions folders are shared among installed JDKs. So when you run JDK 1.5 the javax.script.ScriptEngineManager tries to load classes of JDK 1.6 and you get this error. What I did on my Mac I moved the JDK 1.6 jars into System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext. Awful but works. Maybe also running netbeans without these extension folders may work, not sure if there is something really needed for Apples JDK. ./netbeans -J-Djava.ext.dirs=System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/ Or you can run netbeans on the JDK 1.6 without this problem.
*** Issue 129462 has been marked as a duplicate of this issue. ***
*** Issue 129459 has been marked as a duplicate of this issue. ***
This may be invalid, but our users will run into this problem regardless. Can this bug be re-assigned to someone to make sure it makes it into the release notes or a FAQ or something?
Adding Patric from docs CC to provide the FAQ. The FAQ should contain my #desc5. The most easy solution for user is to run the NB on the JDK 6. Separating libs is not very trivial process, the user needs to find which are 0x2e and which are 0x2f. Specifying java.ext.dirs is also not general solution, someone may have an important library in it. Also someone having the ADC should verify that there is already filled high priority issue on the Apple JDK installer.
OK, here's my attempt: On Mac OS, I get a java.lang.UnsupportedClassVersionError when creating a new Java project. This error can happen if you are running on Mac OS, you have both JDK 5 and JD6 installed, and NetBeans IDE is running on JDK 5. The problem is that the installation of JDK 6 on Mac OS interferes with the JDK 5 installation. The installation of JDK 6 puts some jars with 1.6 bytecode into /System/Library/Java/Extensions, which is shared with all installed JDKs. So when you run on JDK 5, javax.script.ScriptEngineManager tries to load classes of JDK 6, which leads to the error. You can work around this problem in one of the following two ways: * Run the IDE on JDK 6. See http://wiki.netbeans.org/FaqJdkHome for changing the IDE's JDK. * Remove any JDK 6-specific jars from /System/Library/Java/Extensions and put them into System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext.
Good, also adding the link to this issue which lists the stack trace may be helpful.
*** Issue 129605 has been marked as a duplicate of this issue. ***
*** Issue 130215 has been marked as a duplicate of this issue. ***
I just added this faq item (in the project system category) http://wiki.netbeans.org/FaqMacOSProjectError
Is i possible to get some help on what files under /System/Library/Java/Extensions that are JDK 6 specific and needs to be removed to make JDK 5 work again?
Tomas, can you provide a list of those JARs?
It may differ installation from installation but I will provide list of 1.6 jars in my setup (Mac OS X 10.5.2, JDK 1.5 and JDK 1.6) no additional frameworks. I will also provide simple java app checking the version of jar files in ext dirs.
List of class files versions in /System/Library/Java/Version/ /System/Library/Java/Extensions/AppleScriptEngine.jar 1.6 /System/Library/Java/Extensions/CoreAudio.jar 1.4 /System/Library/Java/Extensions/dns_sd.jar 1.4 /System/Library/Java/Extensions/j3daudio.jar 1.3 /System/Library/Java/Extensions/j3dcore.jar 1.3 /System/Library/Java/Extensions/j3dutils.jar 1.3 /System/Library/Java/Extensions/jai_codec.jar 1.3 /System/Library/Java/Extensions/jai_core.jar 1.3 Not a zip file: /System/Library/Java/Extensions/libAppleScriptEngine.jnilib Not a zip file: /System/Library/Java/Extensions/libJ3D.jnilib Not a zip file: /System/Library/Java/Extensions/libJ3DAudio.jnilib Not a zip file: /System/Library/Java/Extensions/libJ3DUtils.jnilib Not a zip file: /System/Library/Java/Extensions/libmlib_jai.jnilib Not a zip file: /System/Library/Java/Extensions/libQTJNative.jnilib Not a zip file: /System/Library/Java/Extensions/libShark.jnilib /System/Library/Java/Extensions/mlibwrapper_jai.jar 1.1 /System/Library/Java/Extensions/MRJToolkit.jar 1.3 /System/Library/Java/Extensions/QTJava.zip 1.2 /System/Library/Java/Extensions/vecmath.jar 1.3 Seems that only problematic jar is AppleScriptEngine.jar, but this may differ in other setup.
Created attachment 59044 [details] Program for listing vm versions of jars
I added info to http://wiki.netbeans.org/FaqMacOSProjectError
*** Issue 131062 has been marked as a duplicate of this issue. ***
Apple development has indicated that they find the behavior of their JDK as expected and they will not change their installer. They have also indicated that NetBeans in particular is searching directories and introspecting classes that it shouldn't be introspecting. They are only willing to pursue this issue further if a short piece of sample code can be supplied to them that does not involve NetBeans and illustrates the same problem. I consider this issue to be reopened since this is going to bite everybody who has JDK 1.5 and JDK 1.6 installed on their Mac and has their default JDK set to 1.5 (unfortunately large development shops are conservative). IMHO providing an FAQ that tells users to change the Apple sanctioned system directory structure is not a good idea ("normal" users might not even have the right to do so).
It's impossible to create a project even downloading the NetBeans beta 6.0.1.
This cannot be fixed in J2SE project, I think (and is not, AFAICT, related to it). Maybe could be fixed by filtering out the problematic jar(s) either in the launcher or in a classloader?
>Apple development has indicated that they find the behavior of their JDK as expected and they will not change their installer. They have also indicated that >NetBeans in particular is searching directories and introspecting classes that it shouldn't be introspecting. What? Expected? In their words each java application is responsible to check if all the classes on java.ext.dirs maybe even on boot classpath are of correct version. But if they don't want to fix it, the NB launcher on Mac could either remove the AppleScriptEngine.jar if running on JDK 1.5 or better can run the class version detector (attached above) and filter out everything where class version > JDK version.
> But if they don't want to fix it, the NB launcher on Mac could either remove the AppleScriptEngine.jar > if running on JDK 1.5 or better can run the class version detector (attached above) and > filter out everything where class version > JDK version. Reassigning to Tomas to evaluate the possibilities in launcher. Anyway, I don't think that running class version detector against the whole bootclasspath is a good idea...
please, consider even the possibility to fix it in the installer (nbi component)
To anebuzelsky: It's a java.ext.dirs, no performance issue. If you decide to hardcode the AppleScriptEngine.jar you are risking that Apple will rename it or add another one. BTW this can be done on demand by the templates module or module system.
I was able to provide Apple with the short test case that they demanded. Let's see if this changes their mind, but this typically takes a few weeks of turnaround time. This simple piece of stand-alone code plus the reference implementation of JSR-223 (Java scripting) triggers the exact same problem: public class TestCase5803680 { public static void main(String[] args) { new javax.script.ScriptEngineManager(); } }
*** Issue 129551 has been marked as a duplicate of this issue. ***
Moving/removing some files in system directories does not seem to me as good idea in general. Moreover, user may not have rights to do so. Of course, this issue should be addressed by Apple. I think solution/workaround in launcher can be to override extension directory (as was suggested by tzezula). If something from extension directory is needed there is possibility to make "local copy" of extension directory and remove invalid files from it.
Local copy sounds better than ignoring the extension folder. The extension folder contains other libs which may be needed. Another solution is to handle this by ClassLoader.
The hack suggested by Jarda, see attached diff seems to works fine, but it changes the bundled scripting api.
Created attachment 59760 [details] Patch
Jarda remarked that overriding of extension folder would disable VM class caching and it could introduce significant performance issue. He proposed mentioned hack as replacement.
Just FYI. The 1.6 provided by Apple is a Non Disclosure Agreement covered release. Among other things, any issue found with it should nto be publicly discussed (as I was repeatedly reminded by apple folks on their mailing lists) While it installs, it doesn't change the default JDK version on the machine. Once they release a final, public version, they will most likely make 1.6 the default JDK.
Created attachment 59778 [details] scripting api with applied patch
I've attached patched scripting api, it can be tested by replacing the file netbeans/platform8/modules/ext/script-api.jar by this patched version.
Regarding mkleint's remark about the NDA: I fully understand this. In this particular case we are hopefully covered though, since in their reply the Apple Developers actively asked me to relay their assessment of the problem to the NetBeans developers to be fixed in NetBeans.
I'm reassigning to tzezula, who agreed to integrate into release61 if tests are successful. Thanks Tomas...
Ok, Tomas as few of the reporters proved that the fix is working for them, I would like to ask you for integration into trunk & proceed with integration into release61 clone as well.
Fixed in trunk: 857d11f15755
The patch looks OK to me. Some background: I see that the jsr-223-api.jar uses sun.misc.Service, which catches just CNFE and Exception when loading a class in Iterator.next(). JDK 6 is the same. The JDK 7 version of SEM uses j.u.ServiceLoader, which appears to catch all Throwable's in the next() method, rendering such a patch unnecessary (since a regular ServiceConfigurationError would be thrown and caught, skipping that provider).
Alternative (non-destructive) workaround. Edit the file /Applications/NetBeans/NetBeans\ 6.1\ Beta.app/Contents/Resources/NetBeans/etc/netbeans.conf add "-J-Djava.ext.dirs=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/" to the definition of "netbeans_default_options".
*** Issue 131524 has been marked as a duplicate of this issue. ***
Integrated into release61: http://hg.netbeans.org/release61/rev/ba53120dc1c9
Is there anybody who can verify the fix in NB 6.1 RC 1 ? Thanks in advance.
The fix works for me. /Brian
*** Issue 134491 has been marked as a duplicate of this issue. ***
*** Issue 134639 has been marked as a duplicate of this issue. ***
*** Issue 137891 has been marked as a duplicate of this issue. ***