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.

Bug 129227 - Can't Create Java-Java Application
Summary: Can't Create Java-Java Application
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: Macintosh All
: P1 blocker (vote)
Assignee: Tomas Zezula
URL: http://statistics.netbeans.org/analyt...
Keywords: JDK_SPECIFIC
: 129459 129462 129551 129605 130215 131062 131524 134491 134639 137891 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-05 07:06 UTC by David Botterill
Modified: 2008-12-22 12:13 UTC (History)
12 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Program for listing vm versions of jars (3.58 KB, text/plain)
2008-03-25 16:47 UTC, Tomas Zezula
Details
Patch (683 bytes, patch)
2008-04-07 11:13 UTC, Tomas Zezula
Details | Diff
scripting api with applied patch (34.86 KB, application/octet-stream)
2008-04-07 16:45 UTC, Tomas Zezula
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Botterill 2008-03-05 07:06:09 UTC
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)
Comment 1 Lukas Hasik 2008-03-05 08:38:45 UTC
reassigning to j2seproject. We tried to reproduce on Mac - without success
Comment 2 Jiri Prox 2008-03-05 09:50:04 UTC
Where did you get the build? Did you download it from NB web or did you compile it yourself?
Comment 3 David Botterill 2008-03-05 10:26:50 UTC
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.
Comment 4 Tomas Zezula 2008-03-05 11:52:50 UTC
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.
Comment 5 Lukas Hasik 2008-03-07 10:31:37 UTC
*** Issue 129462 has been marked as a duplicate of this issue. ***
Comment 6 Jana Maleckova 2008-03-07 14:13:33 UTC
*** Issue 129459 has been marked as a duplicate of this issue. ***
Comment 7 William Leonard 2008-03-07 16:09:26 UTC
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?
Comment 8 Tomas Zezula 2008-03-07 16:57:40 UTC
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.
Comment 9 Patrick Keegan 2008-03-07 17:37:28 UTC
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.

Comment 10 Tomas Zezula 2008-03-08 08:26:13 UTC
Good, also adding the link to this issue which lists the stack trace may be helpful.

Comment 11 Lukas Hasik 2008-03-10 09:04:45 UTC
*** Issue 129605 has been marked as a duplicate of this issue. ***
Comment 12 Jiri Prox 2008-03-17 09:52:32 UTC
*** Issue 130215 has been marked as a duplicate of this issue. ***
Comment 13 Patrick Keegan 2008-03-17 10:34:27 UTC
I just added this faq item (in the project system category) http://wiki.netbeans.org/FaqMacOSProjectError
Comment 14 ceml 2008-03-17 18:17:54 UTC
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?

Comment 15 Patrick Keegan 2008-03-18 18:09:43 UTC
Tomas, can you provide a list of those JARs?
Comment 16 Tomas Zezula 2008-03-23 09:13:07 UTC
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.
Comment 17 Tomas Zezula 2008-03-25 16:45:49 UTC
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.

Comment 18 Tomas Zezula 2008-03-25 16:47:40 UTC
Created attachment 59044 [details]
Program for listing vm versions of jars
Comment 19 Patrick Keegan 2008-03-25 17:19:32 UTC
I added info to http://wiki.netbeans.org/FaqMacOSProjectError
Comment 20 Tomas Zezula 2008-03-26 09:31:28 UTC
*** Issue 131062 has been marked as a duplicate of this issue. ***
Comment 21 teacy123 2008-04-04 00:20:59 UTC
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).

Comment 22 javathreads 2008-04-04 00:43:47 UTC
It's impossible to create a project even downloading the NetBeans beta 6.0.1.
Comment 23 Jan Lahoda 2008-04-04 07:33:41 UTC
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?
Comment 24 Tomas Zezula 2008-04-04 07:48:02 UTC
>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.
 
Comment 25 Antonin Nebuzelsky 2008-04-04 16:07:57 UTC
> 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...
Comment 26 Lukas Hasik 2008-04-04 16:14:13 UTC
please, consider even the possibility to fix it in the installer (nbi component)
Comment 27 Tomas Zezula 2008-04-04 16:45:34 UTC
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.
Comment 28 teacy123 2008-04-04 23:38:00 UTC
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();
}
}


Comment 29 Marian Mirilovic 2008-04-07 08:46:20 UTC
*** Issue 129551 has been marked as a duplicate of this issue. ***
Comment 30 t_h 2008-04-07 09:32:55 UTC
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.
Comment 31 Tomas Zezula 2008-04-07 10:16:14 UTC
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.
Comment 32 Tomas Zezula 2008-04-07 11:12:31 UTC
The hack suggested by Jarda, see attached diff seems to works fine, but it changes the bundled scripting api.
Comment 33 Tomas Zezula 2008-04-07 11:13:23 UTC
Created attachment 59760 [details]
Patch
Comment 34 t_h 2008-04-07 13:26:21 UTC
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.
Comment 35 Milos Kleint 2008-04-07 13:51:25 UTC
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.

Comment 36 Tomas Zezula 2008-04-07 16:45:07 UTC
Created attachment 59778 [details]
scripting api with applied patch
Comment 37 Tomas Zezula 2008-04-07 16:46:51 UTC
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.
Comment 38 teacy123 2008-04-07 23:56:43 UTC
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.

Comment 39 David Simonek 2008-04-08 09:56:44 UTC
I'm reassigning to tzezula, who agreed to integrate into release61 if tests are successful. Thanks Tomas...
Comment 40 Marian Mirilovic 2008-04-08 10:17:57 UTC
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.
Comment 41 Tomas Zezula 2008-04-08 15:35:33 UTC
Fixed in trunk: 857d11f15755
Comment 42 Jesse Glick 2008-04-08 17:37:47 UTC
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).
Comment 43 fommil 2008-04-08 20:44:51 UTC
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".
Comment 44 Petr Hejl 2008-04-08 20:50:35 UTC
*** Issue 131524 has been marked as a duplicate of this issue. ***
Comment 45 Tomas Zezula 2008-04-09 08:18:26 UTC
Integrated into release61: http://hg.netbeans.org/release61/rev/ba53120dc1c9
Comment 46 Marian Mirilovic 2008-04-11 12:01:46 UTC
Is there anybody who can verify the fix in NB 6.1 RC 1 ? Thanks in advance.
Comment 47 William Leonard 2008-04-11 15:40:08 UTC
The fix works for me. /Brian
Comment 48 Jan Horvath 2008-05-05 17:18:56 UTC
*** Issue 134491 has been marked as a duplicate of this issue. ***
Comment 49 Jan Lahoda 2008-05-07 18:22:50 UTC
*** Issue 134639 has been marked as a duplicate of this issue. ***
Comment 50 Milos Kleint 2008-06-23 08:44:17 UTC
*** Issue 137891 has been marked as a duplicate of this issue. ***