[GRADLE-3046] NoClassDefFoundError on a JavaFX class in compileGroovy task on Java 8 Created: 13/Mar/14 Updated: 15/Jul/15 Resolved: 15/Jul/15 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.4-rc-1 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Daz DeBoer |
Resolution: | Fixed | Votes: | 4 |
Description |
I'm running on a Java 8 release candidate (b129) & I have groovy code that references the built-in class javafx.scene.chart.Chart. The compileGroovy task chokes on that reference & produces a NoClassDefFoundError (full stack trace is below). Having found This worked. Perhaps this is due to jfxrt.jar having moved from lib in Java 7 to lib/ext in Java 8? Is that the best workaround? I'd rather not have this redundant dependency in my build. Thanks, Neil Gradle -v output is: Build time: 2014-02-11 11:34:39 UTC Groovy: 1.8.6 Exception is: |
Comments |
Comment by Gradle Forums [ 13/Mar/14 ] |
The issues you link to are unrelated. Have you checked if plain javac puts JavaFX on the class path automatically? I wouldn't think so. |
Comment by Gradle Forums [ 13/Mar/14 ] |
Yes, in java 8, javafx is on the class path automatically. In this forum topic: [1]http://gsfn.us/t/43gq4, you said: "Could be the known Groovy compiler problem that the Groovy compiler sometimes needs runtime dependencies on the compile class path." That was what gave me the idea above (sorry about the unrelated issues). |
Comment by Gradle Forums [ 13/Mar/14 ] |
Even if javac always has JavaFX on its compile class path, this may not be the case for groovyc. That's likely the problem. |
Comment by Gradle Forums [ 13/Mar/14 ] |
I renamed the .java test file to .groovy & it compiles & runs fine. I added @CompileStatic onto the class & it still compiles & runs fine. This is my declaration of my groovy dependency: |
Comment by Gradle Forums [ 13/Mar/14 ] |
By the way, thank you for Spock, Peter, it is excellent! |
Comment by Gradle Forums [ 13/Mar/14 ] |
Which Java test file are you suddenly speaking of? I thought that the problem is that Groovy production code that references JavaFX classes doesn't compile. (After all, the task that failed is `:framework:compileGroovy`). You may have to describe the problem in more detail, but I doubt there is a better solution than the one you've already found. |
Comment by Gradle Forums [ 13/Mar/14 ] |
When you asked if the java compiler puts jfxrt.jar on the class path, I used the HelloWorld program from [1]http://docs.oracle.com/javafx/2/get_s... as a simple example to verify that it does. When you asked if the groovy compiler does the same, I used that same JavaFX program to verify that the current groovy compiler does the same. When that HelloWorld.groovy program is compiled by compileGroovy with the following build.gradle: apply plugin: 'groovy' repositories { dependencies { It produces errors like: C:\tmp\src\main\groovy\HelloWorldFX.groovy: 2: unable to resolve class javafx.event.ActionEvent I hope this bug in the compileGroovy task when run under Java 8 can be fixed at some point. Until then, we can use our current workaround. |