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 167240 - Cannot create project on Mac OS X after upgrade of JDK
Summary: Cannot create project on Mac OS X after upgrade of JDK
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Templates (show other bugs)
Version: 6.x
Hardware: Macintosh Mac OS X
: P1 blocker with 1 vote (vote)
Assignee: Milan Kubec
URL: http://statistics.netbeans.org/analyt...
Keywords: JDK_SPECIFIC, REGRESSION
: 167268 167617 167685 167722 168645 168719 184986 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-17 14:52 UTC by Jaromir Uhrik
Modified: 2010-04-27 13:58 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (533 bytes, patch)
2009-06-19 08:24 UTC, Milan Kubec
Details | Diff
jar file with the fix (platform/modules/ext/script-api.jar) (34.97 KB, application/octet-stream)
2009-06-19 08:27 UTC, Milan Kubec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaromir Uhrik 2009-06-17 14:52:03 UTC
Product Version: NetBeans IDE 6.7 RC3 (Build 200906142201)
Java: 1.5.0_19; Java HotSpot(TM) Client VM 1.5.0_19-137
System: Mac OS X version 10.5.7 running on i386; MacRoman; en_US (nb)

After the update of JDK on Mac OS X it is not possible to create project. 
When I create new J2SE project the wizard stops and the exception appears:

java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
	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:209)
	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:129)
	at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler.accept(ScriptingCreateFromTemplateHandler.java:70)
	at org.openide.loaders.MultiDataObject.handleCreateFromTemplate(MultiDataObject.java:707)
	at org.openide.loaders.DefaultDataObject.handleCreateFromTemplate(DefaultDataObject.java:159)
	at org.openide.loaders.DataObject$CreateAction.run(DataObject.java:1288)
	at org.openide.loaders.DataObjectPool$1WrapAtomicAction.run(DataObjectPool.java:258)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:509)
	at org.openide.loaders.DataObjectPool.runAtomicAction(DataObjectPool.java:270)
	at org.openide.loaders.DataObject.invokeAtomicAction(DataObject.java:873)
	at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:805)
	at org.openide.loaders.DataObject.createFromTemplate(DataObject.java:785)
	at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createMainClass(J2SEProjectGenerator.java:381)
	at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.access$200(J2SEProjectGenerator.java:78)
	at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator$1.run(J2SEProjectGenerator.java:114)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:509)
	at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createProject(J2SEProjectGenerator.java:95)
	at
org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator.instantiate(NewJ2SEProjectWizardIterator.java:182)
	at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1016)
	at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:588)
	at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:409)
	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:1524)
	at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1481)
	at org.openide.WizardDescriptor.access$1700(WizardDescriptor.java:127)
	at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2052)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:577)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1030)


With previous version JDK build 1.5.0_16-133 everything worked properly. Now the workaround is to start NetBeans with
jdkhome switch pointing to JDK6.
Seems like the problem is similar to 
http://www.netbeans.org/issues/show_bug.cgi?id=129227
Comment 1 stesun 2009-06-18 00:46:43 UTC
I suspect the issue is the same as with 6.5.1, see http://www.netbeans.org/issues/show_bug.cgi?id=167188
Don't know if the scripting-api.jar is still included with 6.7 though since I'm using 6.5.1
Comment 2 Erno Mononen 2009-06-18 08:57:35 UTC
*** Issue 167268 has been marked as a duplicate of this issue. ***
Comment 3 Milan Kubec 2009-06-18 15:14:59 UTC
Please review the patch for jsr223.jar

ScriptEngineManager.java
136a137,146
>                 } catch (UnsupportedClassVersionError err) {
>                     if (DEBUG) {
>                         err.printStackTrace();
>                     }
>                     continue;
>                 } catch (NoClassDefFoundError ncdfe) {
>                     if (DEBUG) {
>                         ncdfe.printStackTrace();
>                     }
>                     continue;
Comment 4 Martin Schovanek 2009-06-18 16:53:23 UTC
Verified in custom build by QE, please transplant into release_67.
Comment 5 Milan Kubec 2009-06-18 16:57:36 UTC
Fixed in core-main and release67.
http://hg.netbeans.org/core-main/rev/2c89ca25465f
http://hg.netbeans.org/release67/rev/f5e6c212c0fb
Comment 6 Jesse Glick 2009-06-18 17:31:06 UTC
The patch does not explain what was really wrong on the Mac. A full explanation belongs here in IZ.

Would this be better fixed by adding to libs.jsr223/manifest.mf:

OpenIDE-Module-Hide-Classpath-Packages: javax.script.**

?
Comment 7 Quality Engineering 2009-06-19 07:46:43 UTC
Integrated into 'main-golden', will be available in build *200906190201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2c89ca25465f
User: Milan Kubec <mkubec@netbeans.org>
Log: #167240: catching and ignoring NCDFE in javax.script.ScriptEngineManager
Comment 8 Milan Kubec 2009-06-19 07:55:26 UTC
The problem on Mac is that JDK 5 and JDK 6 both see /System/Library/Java/Extensions/AppleScriptEngine.jar and this jar
when NB scripting module (running on JDK 5) wants to load all impls. for javax.script will be loaded by boot
classloader, but this classloader cannot see javax.script package on JDK 5 because only NB module classloader can see
it. We already had this problem, but it was manifested by "UnsupportedClassVersionError: Bad version number in .class
file" (see issue #129227), because that jar was compiled by JDK 6, so out first fix was to ignore that error. With
recent JDK update this jar has been updated but this time already compiled by JDK 5, so our catch stopped working, so I
added other catch, this time for NCDFE.

I cannot say whether "OpenIDE-Module-Hide-Classpath-Packages: javax.script.**" in manifest would fix the problem.
Comment 9 Milan Kubec 2009-06-19 08:23:43 UTC
Sources for the javax.script are on http://libs.netbeans.org/servlets/ProjectDocumentList

Patch file for these sources will be attached.
Comment 10 Milan Kubec 2009-06-19 08:24:58 UTC
Created attachment 83790 [details]
Patch
Comment 11 Milan Kubec 2009-06-19 08:27:46 UTC
Created attachment 83791 [details]
jar file with the fix (platform/modules/ext/script-api.jar)
Comment 12 Milan Kubec 2009-06-19 08:30:31 UTC
Attached patch file contains also change already applied when fixing issue #129227.
Comment 13 Martin Schovanek 2009-06-19 15:11:20 UTC
Verified in release67 build by QE.
Comment 14 Jesse Glick 2009-06-19 15:41:11 UTC
Please at least try OIDE-M-H-C-P to see if it works. This would seem to me a cleaner fix than patching the Script API JAR.

The effect would be for NB's module class loader to ignore the specified packages if they happen to be on the
bootclasspath, always using its own. From your description perhaps what you really want is to also/instead ignore the
packages contained in AppleScriptEngine.jar, whatever those are.
Comment 15 Milan Kubec 2009-06-22 08:55:11 UTC
From your description it would probably work, but I don't know if it's what we want to do. The fix you are proposing
would change also loading of scripting frameworks for JDK 6 and above and I'm not sure we want to do it. 

The fix is only because of JDK 5, but it will reach its End of Service Life on October 30th, 2009. So it's highly
probable that we won't support JDK 5 after this date.
Comment 16 Jesse Glick 2009-06-22 16:51:43 UTC
Yes, of course when we drop JDK 5 support then we can simply delete libs.jsr223, so it will no longer be an issue.
Comment 17 Jaroslav Tulach 2009-06-23 13:30:27 UTC
> Please at least try OIDE-M-H-C-P to see if it works.

I can bet five beers that it does not work.
Comment 18 Marian Mirilovic 2009-06-24 23:31:05 UTC
*** Issue 167617 has been marked as a duplicate of this issue. ***
Comment 19 Milan Kubec 2009-06-26 10:21:53 UTC
*** Issue 167685 has been marked as a duplicate of this issue. ***
Comment 20 Erno Mononen 2009-07-08 09:55:22 UTC
*** Issue 167722 has been marked as a duplicate of this issue. ***
Comment 21 Jiri Rechtacek 2009-07-21 09:42:27 UTC
*** Issue 168645 has been marked as a duplicate of this issue. ***
Comment 22 greggwon 2009-07-22 16:40:20 UTC
One of the things that occurs to me, is that perhaps there is not the correct classloader mechanisms involved here.  The
Jini platform, along time ago, starting providing the PreferredClassLoader and PreferredClassProvider (for the SPI) that
allows jar files to contain META-INF/PREFERRED.LIST as a list that indicates preferred packages and classes.  What this
provides, is the ability for a jar to substitute "working" for "broken" platform classes so that the jar can guarantee
that it gets the correct version of a class that it knows will provide the proper implementation.

This really helps tremendously in making sure that platforms are platforms and that impls can be provided for particular
Jars to use so that things that are not shared beyond a particular class loader root can be provided by jars that need
specific implementations with no worries about class name conflicts.

This would also help compartmentalize the platform module mechanism to allow modules to truly be standalone.
Comment 23 Jesse Glick 2009-07-22 17:22:43 UTC
What greggwon describes is essentially OpenIDE-Module-Hide-Classpath-Packages, I think. We decided that we will not
bother with this since the issue becomes moot once JDK 5 support is dropped.
Comment 24 Peter Pis 2009-08-20 14:27:04 UTC
*** Issue 168719 has been marked as a duplicate of this issue. ***
Comment 25 Jaroslav Tulach 2010-04-27 13:58:52 UTC
*** Bug 184986 has been marked as a duplicate of this bug. ***