1

I have a JavaFX project and ran the Maven pom:

mvn gluonfx:compile -f pom_graalvm.xml

This includes the GluonFX plugin gluonfx-maven-plugin version 1.0.19.

The build fails and from the log file have the following, and appears to be an internal error:

[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB] 
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB] [1/7] Initializing...                                                                                    (0.0s @ 0.22GB)
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB] Fatal error: java.lang.IllegalAccessError: class com.gluonhq.substrate.feature.GluonFeature (in unnamed module @0x6614bd4b) cannot access class com.oracle.svm.core.jdk.NativeLibrarySupport (in module org.graalvm.nativeimage.builder) because module org.graalvm.nativeimage.builder does not export com.oracle.svm.core.jdk to unnamed module @0x6614bd4b
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB]  at com.gluonhq.substrate.feature.GluonFeature.duringSetup(GluonFeature.java:58)
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$16(NativeImageGenerator.java:918)
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85)
[Fri Jul 14 17:11:36 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:918)
...

Has anyone any idea what is wrong?

I have successfully built this JavaFX project with an almost identical pom.xml without the GluonFX plugin and it builds and works fine. It's a long established project but as soon as I add the GluonFX plugin and try to build, I can't get anywhere.

Thanks

I'm using Linux Mint21, Java 17, JavaFX 20.0.1

*** Update ***

Now I'm totally baffled. I thought I'd try Java20 and downloaded graalvm-community-openjdk-20.0.1+9.1 from [https://github.com/graalvm/graalvm-ce-builds/releases].

I then generated the sample at [https://start.gluon.io/].

Again, it runs OK, but when I enter "mvn gluonfx:build gluonfx:nativerun" I get:

[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] Produced artifacts:
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  /home/gmseed/programming/gluon/java20/my-gluon-application/target/gluonfx/x86_64-linux/gvm/My Gluon Application/svm_err_b_20230716T094746.136_pid3989.md (build_info)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] ========================================================================================================================
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] Failed generating 'com.mycompany.sample.main' after 5.5s.
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] 
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] The build process encountered an unexpected error:
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] 
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] java.lang.IllegalAccessError: class com.gluonhq.substrate.feature.GluonFeature (in unnamed module @0x2c4ca0f9) cannot access class com.oracle.svm.core.jdk.NativeLibrarySupport (in module org.graalvm.nativeimage.builder) because module org.graalvm.nativeimage.builder does not export com.oracle.svm.core.jdk to unnamed module @0x2c4ca0f9
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at com.gluonhq.substrate.feature.GluonFeature.duringSetup(GluonFeature.java:58)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$16(NativeImageGenerator.java:938)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:86)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:938)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:579)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)
[Sun Jul 16 09:47:46 BST 2023][INFO] [SUB] 
[Sun Jul 16 09:47:46 BST 2023][SEVERE] Process compile failed with result: 1
...

I also tried using the Oracle GraalVM [https://www.graalvm.org/downloads/#] graalvm-jdk-17.0.7+8.1 and got the same errors. So, looks like the issue is with "mvn gluonfx:build gluonfx:nativerun".

I have now back-tracked through "gluonfx-maven-plugin" Maven plugins and tried with 1.0.18, 1.0.17,... and get the same result.

I have also tried the absolute basic sample at [https://start.gluon.io/] by unchecking everything, and "mvn gluonfx:build gluonfx:nativerun" still fails.

I find it hard to believe that this doesn't work for others and got past development testing. Thus, I'm starting to wonder if this is a Linux issue. Something's clearly not right, but haven't tracked it down yet.

*** Update 2 ***

If you head to [https://github.com/gluonhq/gluon-samples/tree/master/HelloWorld] and run this sample and run the command "mvn gluonfx:runagent" it works but you will see in the output:

"INFO: Substrate is tested with the Gluon's GraalVM build which you can find at https://github.com/gluonhq/graal/releases. While you can still use other GraalVM builds, there is no guarantee that these will work properly with Substrate"

So, I headed to [https://github.com/gluonhq/graal/releases] and installed "graalvm-svm-java17-linux-gluon-22.1.0.1-Final" and tried that. This time it got a bit further with "mvn gluonfx:build" but in the end failed, with even more errors:

...
[INFO] --- gluonfx-maven-plugin:1.0.19:link (default-cli) @ myapplication ---
[Mon Jul 17 11:11:52 BST 2023][INFO] ==================== LINK TASK ====================
[Mon Jul 17 11:11:52 BST 2023][SEVERE] Process Get config for libavcodec failed with result: 1
Check the log files under /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/x86_64-linux/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Mon Jul 17 11:11:52 BST 2023][INFO] Logging process [Get config for libavcodec] to file: /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/log/process-Get config for libavcodec-1689588712820.log
[Mon Jul 17 11:11:52 BST 2023][SEVERE] Process Get config for libavformat failed with result: 1
Check the log files under /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/x86_64-linux/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Mon Jul 17 11:11:52 BST 2023][INFO] Logging process [Get config for libavformat] to file: /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/log/process-Get config for libavformat-1689588712826.log
[Mon Jul 17 11:11:52 BST 2023][SEVERE] Process Get config for libavutil failed with result: 1
Check the log files under /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/x86_64-linux/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Mon Jul 17 11:11:52 BST 2023][INFO] Logging process [Get config for libavutil] to file: /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/log/process-Get config for libavutil-1689588712832.log
[Mon Jul 17 11:11:52 BST 2023][SEVERE] Process Get config for alsa failed with result: 1
Check the log files under /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/x86_64-linux/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Mon Jul 17 11:11:52 BST 2023][INFO] Logging process [Get config for alsa] to file: /home/gmseed/programming/gluon/java17/minimal app/my-gluon-application/target/gluonfx/log/process-Get config for alsa-1689588712837.log
[Mon Jul 17 11:11:52 BST 2023][INFO] Cannot link because some development libraries are missing.
Please install OS packages:
  libasound2-dev (for pkgConfig alsa)
  libavcodec-dev (for pkgConfig libavcodec)
  libavformat-dev (for pkgConfig libavformat)
  libavutil-dev (for pkgConfig libavutil)
java.lang.IllegalStateException: Missing linker libraries
    at com.gluonhq.substrate.util.linux.LinuxLinkerFlags.printUpdateInstructionsAndFail(LinuxLinkerFlags.java:179)
    at com.gluonhq.substrate.util.linux.LinuxLinkerFlags.doGetLinkerFlags(LinuxLinkerFlags.java:135)
    at com.gluonhq.substrate.util.linux.LinuxLinkerFlags.getMediaLinkerFlags(LinuxLinkerFlags.java:125)
    at com.gluonhq.substrate.target.LinuxTargetConfiguration.getTargetSpecificLinkFlags(LinuxTargetConfiguration.java:293)
    at com.gluonhq.substrate.target.AbstractTargetConfiguration.link(AbstractTargetConfiguration.java:214)
    at com.gluonhq.substrate.target.LinuxTargetConfiguration.link(LinuxTargetConfiguration.java:127)
    at com.gluonhq.substrate.SubstrateDispatcher.nativeLink(SubstrateDispatcher.java:444)
    at com.gluonhq.NativeLinkMojo.execute(NativeLinkMojo.java:47)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:25 min
[INFO] Finished at: 2023-07-17T11:11:52+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.19:link (default-cli) on project myapplication: Error: Missing linker libraries -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:27 min
[INFO] Finished at: 2023-07-17T11:11:52+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.19:build (default-cli) on project myapplication: Error, gluonfx:build failed -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I find the whole experience pretty poor that you can't even build a HelloWorld JavaFX GraalVM app without all these issues. What's it going to be like when I point it to a 1 million line app?

*** Update 3 ***

The output stated that the following had to installed:

Please install OS packages: libasound2-dev (for pkgConfig alsa) libavcodec-dev (for pkgConfig libavcodec) libavformat-dev (for pkgConfig libavformat) libavutil-dev (for pkgConfig libavutil)

and installed them using the following, changing the required lib each time:

sudo apt-get install -y libasound2-dev

I then had to go round this loop a few times, each time installing the libs it was complaining about.

*** Result ***

Eventually, after 4 days of trying to get a Java17 - JavaFX - Maven - GraalVM HelloWorld app to build in native form and run, I got it to work.

Thus - the key message here is that if you intend using gluon Maven plugin and commands such as "mvn gluonfx:build gluonfx:nativerun" then make sure you use their own version of GraalVM.

Graham Seed
  • 742
  • 3
  • 10
  • 24
  • 1
    It is a [module error](https://stackoverflow.com/questions/53237287/module-error-when-running-javafx-media-application). I don't use Gluon or GraalVM and have no further advice. – jewelsea Jul 14 '23 at 18:23
  • 1
    What is your GraalVM version? If you use the Gluon build (see docs) you shouldn’t get this error – José Pereda Jul 14 '23 at 21:17
  • GraalVM version: graalvm-ce-java17-22.3.1 – Graham Seed Jul 15 '23 at 08:38
  • Went along to [https://start.gluon.io/] and downloaded and ran the sample app there and got the same error messages. "mvn gluonfx:run" worked but "mvn gluonfx:build gluonfx:nativerun" generates the same errors as originally posted. – Graham Seed Jul 15 '23 at 13:38
  • Tried with both JavaFX 17 and 20 and get the same result. – Graham Seed Jul 15 '23 at 13:44
  • Tried also with graalvm-ce-java17-22.3.0 and graalvm-ce-java17-22.3.1 and got the same error with the [start.gluon.io/] sample. – Graham Seed Jul 15 '23 at 20:31
  • You can edit the question to add more info, sometimes that is more useful than adding comments. – jewelsea Jul 15 '23 at 20:47
  • Added an "Update" section to the main post. – Graham Seed Jul 16 '23 at 08:53
  • You can fix this particular type of errors by adding `--add-modules` parameters. The syntax is the same as in Java. Another idea is to run in verbose mode and inspect `native-image` command line to try to spot irregularities – peterz Jul 16 '23 at 17:32
  • With "mvn gluonfx:build gluonfx:nativerun", how does one add --add-modules? When I finally have the "standalone" GraalVM app isn't the idea I simply go "./app" and do't use --add-modules, and would that even work? – Graham Seed Jul 17 '23 at 08:46
  • The inability to not be able to edit a comment after 5 mins has elapsed is stupid. – Graham Seed Jul 17 '23 at 08:53
  • [Why can't I edit my comment after 5 minutes but can delete and create a new one?](https://meta.stackoverflow.com/questions/292238/why-cant-i-edit-my-comment-after-5-minutes-but-can-delete-and-create-a-new-one) – Abra Jul 17 '23 at 09:51
  • Using the Gluon build of GraalVM (22.1.0.1-Final) works with the GluonFX plugin as expected (you had to install some missing packages in your Linux distribution, but only the first time, and those were properly listed). Using the official GraalVM version instead with GluonFX, while supported somehow, has some chances that it might fail. In your case, you are using a modular project, and the new GraalVM versions have better support for modular applications (therefore the need to go back to an older version, or to use `--add-modules` as suggested, with ``). – José Pereda Jul 17 '23 at 15:21

0 Answers0