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 239388 - [80cat] JavaFX 7u45/7u51 Project: Successfully built project won't run or debug
Summary: [80cat] JavaFX 7u45/7u51 Project: Successfully built project won't run or debug
Status: VERIFIED FIXED
Alias: None
Product: javafx
Classification: Unclassified
Component: Project (show other bugs)
Version: 8.0
Hardware: PC Windows 8
: P2 normal with 3 votes (vote)
Assignee: Roman Svitanic
URL:
Keywords: 8.0_WAIVER_APPROVED
: 239927 240314 240505 240506 241677 (view as bug list)
Depends on: 240105
Blocks:
  Show dependency tree
 
Reported: 2013-12-11 21:36 UTC by Lou Dasaro
Modified: 2015-10-09 18:50 UTC (History)
12 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
"Run" output from NetBeans (3.05 KB, text/plain)
2013-12-11 21:36 UTC, Lou Dasaro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lou Dasaro 2013-12-11 21:36:34 UTC
Created attachment 143080 [details]
"Run" output from NetBeans

JavaFX projects generated using JDK 7u45, once successfully built, won't run from the IDE, and errors are displayed (see attachment). However, the compiled /dist/JavaFXApplicationNN.jar runs just fine launching from the file system.

Also, If you change platform to JDK 8 and rebuild, it will run in the IDE. See also related error.
Comment 1 Lou Dasaro 2013-12-11 21:42:03 UTC
Product Version: NetBeans IDE Dev (Build 201312090002)
Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b60
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b118
System: Windows 8 version 6.2 running on x86; Cp1252; en_US (nb)
Comment 2 Lou Dasaro 2013-12-12 00:29:19 UTC
This error does NOT occur when NetBeans is running on 7u45. It DOES occur when running on JDK 8.
Comment 3 Roman Svitanic 2013-12-12 16:23:09 UTC
Thanks for the report.

Problem is that ant-javafx.jar (which contains FX ant tasks) from JDK8 (in this case, but generally from the default platform on which IDE runs) is present on the bootclasspath. Therefore ant uses tasks from this jar instead of the one from JDK7 project platform.
We have to investigate why this jar is on bootclasspath and which module put it there.
Comment 4 Lou Dasaro 2014-01-03 05:32:51 UTC
Hi Roman,

This is a pretty important bug, because if a user runs NetBeans on JDK 8, they can't run or debug a program configured to use JDK 7. Developers will probably use latest Java (8), but build for Java 7 since most consumers will still be on Java 7. Bug should be set to priority 2, because I think the only workaround is to tell users to uninstall NetBeans and reinstall it so it runs on JDK 7. I tested again today using:
Product Version: NetBeans IDE Dev (Build 201401020002) (Windows 8.1)
Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b63
Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b121

I hope this can be resolved before NetBeans 8 RC, because I'm thinking the FCS roughly coincides with the date of the official JDK 8 release. 

If I haven't said it already, Happy New Year!
Comment 5 Roman Svitanic 2014-01-03 16:15:00 UTC
Hi Lou, thanks and Happy New Year to you, too!

As I have mentioned earlier, this issue has cause outside the JavaFX modules. Probably some other module puts */**.jar from jdk/lib on cp.

There are few easier workarounds, none of them requires uninstallation of the IDE:
1. Use JDK 8, but set source level to 7.
2. Start NetBeans with --jdkhome switch pointing to JDK 7.
3. Set "netbeans_jdkhome" property in <NetBeans Installation dir>/etc/netbeans.conf.
Comment 6 Roman Svitanic 2014-01-06 16:02:21 UTC
*** Bug 239927 has been marked as a duplicate of this bug. ***
Comment 7 swpalmer 2014-01-06 18:52:54 UTC
Lou wrote: "However, the compiled /dist/JavaFXApplicationNN.jar runs just fine launching from the file system."

This is not how it behaves for me.  The app fails to run with Java 7 even when launching outside of NetBeans.

>"c:\Program Files\Java\jre7\bin\java.exe" -jar dist\AudioVisualizer3D.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/scene/media/AudioSpectrumListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javafx.scene.media.AudioSpectrumListener
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 13 more
Comment 8 Lou Dasaro 2014-01-06 21:01:01 UTC
You are correct, Scott. Today, I ran java -version:1.7.0_45 -jar AudioVisualizer3D.jar, and it failed as you described.
Comment 9 Lou Dasaro 2014-01-08 08:42:25 UTC
*** Bug 240105 has been marked as a duplicate of this bug. ***
Comment 10 Lou Dasaro 2014-01-12 08:12:30 UTC
*** Bug 240314 has been marked as a duplicate of this bug. ***
Comment 11 Roman Svitanic 2014-01-15 16:25:56 UTC
*** Bug 240505 has been marked as a duplicate of this bug. ***
Comment 12 Roman Svitanic 2014-01-15 16:32:11 UTC
*** Bug 240506 has been marked as a duplicate of this bug. ***
Comment 13 Roman Svitanic 2014-02-11 08:39:46 UTC
*** Bug 241677 has been marked as a duplicate of this bug. ***
Comment 14 Lou Dasaro 2014-02-19 05:57:45 UTC
Roman's solution is a good one, my feeling is that Priority could be changed to 3 so long as this becomes well-documented. For now, I'm just going to add a little detail here:
The short answer to being able to develop in JDK 8 _and_ JDK 7 (alternately) with NetBeans 8.0 is as follows:
Start NetBeans with --jdkhome switch pointing to JDK 7.
In Windows, for example, you can change the shortcut so that it looks similar to this:

"C:\Program Files\NetBeans Dev 201402160001\bin\netbeans.exe" --jdkhome "C:\Program Files\Java\jdk1.7.0_51"

Alternatively, you could set the "netbeans_jdkhome" property in <NetBeans Installation dir>/etc/netbeans.conf e.g.
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_51"

In either case, the project's source level must be 7 or lower to build with JDK 7, which it does just fine, and runs both in the IDE as well as jars from the command line.

In addition, even though jdkhome is set to 1.7.0_nn, you can still set the target and source level to JDK 8 if you want to code to that environment, for example, adding Lambda expressions.
Comment 15 Lou Dasaro 2014-03-19 17:53:11 UTC
For the official NetBeans 8.0 release, the workaround is documented at 
https://netbeans.org/community/releases/80/relnotes.html#known_issues-javafx
Comment 16 Lou Dasaro 2014-04-16 02:40:33 UTC
Problem continues under:

Product Version: NetBeans IDE Dev (Build 201404150001)
Java: 1.8.0_05; Java HotSpot(TM) Client VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13

with a target of 1.7.0_55
Comment 17 Marian Mirilovic 2014-04-18 12:16:53 UTC
Roman, any chance to fix it into Patch 1 ?
Comment 18 Roman Svitanic 2014-04-18 13:50:26 UTC
(In reply to Marian Mirilovic from comment #17)
> Roman, any chance to fix it into Patch 1 ?

Difficult to say, since it's still under investigation. We don't know which module (it isn't any JavaFX-related module) puts all jars (including ant-javafx.jar) from lib folder from platform on which IDE runs on classpath.

Adding Tomas on CC.
Comment 19 zmirc 2014-09-23 19:51:49 UTC
I just ran into this issue as well with NetBeans 8.0.1 on JDK 8. It's pretty annoying. Any progress? Any chance for a fix?
Comment 20 Lou Dasaro 2014-09-24 19:17:22 UTC
zmirc: Are you not able to use the workaround described in my comment of 2014-02-19?

Roman: Did someone file a ticket in the JavaFX Jira for this?
Comment 21 Tomas Mysik 2015-09-04 06:04:21 UTC
I can confirm that this is issue of NetBeans. If I run Ant from command line [1], it works as expected (proper application JAR is built). So, this could be an ugly workaround. Another ugly workaround could be to delete (move somewhere) JavaFx Ant JAR [2] and run NetBeans. Of course, this has consequences (one cannot develop JavaFx application on JDK8).

[1] ant jar
[2] <JDK8>/lib/ant-javafx.jar
Comment 22 Lou Dasaro 2015-09-08 02:06:56 UTC
Tomas, the "official" workaround was documented at https://netbeans.org/community/releases/80/relnotes.html#known_issues-javafx

Does this not work for you?
Comment 23 Tomas Mysik 2015-09-08 07:27:23 UTC
(In reply to Lou Dasaro from comment #22)
> Tomas, the "official" workaround was documented at
> https://netbeans.org/community/releases/80/relnotes.html#known_issues-javafx
> 
> Does this not work for you?

My workaround is if you have only JDK8 available (and no JDK7).
Comment 24 Tomas Zezula 2015-09-08 09:28:56 UTC
The problem is in AntBridge.createMainClassLoader() which adds all jars from jdk/lib to ClassLoader[ExtClassLoader].

The code was changed in the JDK9 branch to prefer Inverse ClassLoader in order to support both pre JDK9 (rt.jar) layout and JDK 9 module images. This change fixed also this problem when tools.jar is on IDEs classpath (in Java IDE it is).


http://hg.netbeans.org/jet-main/file/e332ef83926a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/AntBridge.java
Comment 25 Tomas Mysik 2015-09-08 11:16:40 UTC
(In reply to Tomas Zezula from comment #24)
> The problem is in AntBridge.createMainClassLoader() which adds all jars from
> jdk/lib to ClassLoader[ExtClassLoader].
> 
> The code was changed in the JDK9 branch to prefer Inverse ClassLoader in
> order to support both pre JDK9 (rt.jar) layout and JDK 9 module images. This
> change fixed also this problem when tools.jar is on IDEs classpath (in Java
> IDE it is).
> 
> 
> http://hg.netbeans.org/jet-main/file/e332ef83926a/o.apache.tools.ant.module/
> src/org/apache/tools/ant/module/bridge/AntBridge.java

So, I suggest closing as FIXED with TM Next - any objections?

Thanks.
Comment 26 Lou Dasaro 2015-10-06 05:12:55 UTC
Problem occurs on 8.1 RC. Maybe it will be fixed in a future release, but it hasn't been fixed yet.
Comment 27 Tomas Mysik 2015-10-06 06:58:46 UTC
The Target Milestone is set to Dev - that is not 8.1 but the current dev version. It means that it will be fixed in the version after 8.1 (likely 9.0). See comment #24 for more information.

Thanks.
Comment 28 Lou Dasaro 2015-10-09 18:50:39 UTC
Verified FIXED using JDK 9 branch ONLY.
Product Version: NetBeans Dev JDK9 branch (Build 201506180405)
Java: 1.9.0-ea; Java HotSpot(TM) Client VM 1.9.0-ea-b82
Runtime: Java(TM) SE Runtime Environment 1.9.0-ea-b82
System: Windows 8.1 version 6.3 running on x86; Cp1252; en_US (nb)

Remains an issue for NetBeans 8.1. See https://netbeans.org/community/releases/81/relnotes.html#known_issues