Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX native-image build failing #385

Open
HeartOfGlass404 opened this issue Jan 12, 2023 · 1 comment
Open

JavaFX native-image build failing #385

HeartOfGlass404 opened this issue Jan 12, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@HeartOfGlass404
Copy link

To Reproduce
Steps to reproduce the behavior:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http:https://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <profiles>
        <profile>
            <id>native</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>java-agent</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>java</executable>
                                    <workingDirectory>${project.build.directory}</workingDirectory>
                                    <arguments>
                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <argument>${mainClass}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>native</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${project.build.directory}/${imageName}</executable>
                                    <workingDirectory>${project.build.directory}</workingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native.maven.plugin.version}</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>build-native</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                            <execution>
                                <id>test-native</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>test</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <fallback>false</fallback>
                            <buildArgs>
                                <arg>-H:DashboardDump=covid -H:+DashboardAll</arg>
                            </buildArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <modelVersion>4.0.0</modelVersion>


    <groupId>adianov.sergei</groupId>
    <artifactId>COVID-Risk</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>COVID-Risk</name>

    <properties>
        <javafx.version>19-ea+7</javafx.version>
        <graalvm.version>22.3.0</graalvm.version>
        <native.maven.plugin.version>0.9.18</native.maven.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.8.2</junit.version>
        <maven.compiler.source>${java.specification.version}</maven.compiler.source>
        <maven.compiler.target>${java.specification.version}</maven.compiler.target>
        <imageName>COVID Risk</imageName>
        <mainClass>adianov.sergei.covidrisk.MainApp</mainClass>
    </properties>

    <dependencies>


        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>5.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/exec-maven-plugin -->
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>19-ea+7</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>19-ea+7</version>
        </dependency>

        <dependency>
            <groupId>org.controlsfx</groupId>
            <artifactId>controlsfx</artifactId>
            <version>11.1.1</version>
        </dependency>

        <dependency>
            <groupId>com.dlsc.formsfx</groupId>
            <artifactId>formsfx-core</artifactId>
            <version>11.5.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.openjfx</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.graalvm.sdk</groupId>
            <artifactId>graal-sdk</artifactId>
            <version>${graalvm.version}</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <version>0.9.18</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--The plugin figures out what jar files it needs to pass to the native image
                    and what the executable main class should be. -->
                    <!--<mainClass>${app.mainClass}</mainClass>-->
                    <imageName>Covid-risk</imageName>
                    <buildArgs>
                        --no-fallback
                    </buildArgs>
                    <skip>false</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>java</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>adianov.sergei.covidrisk.MainApp</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <executable>D:\Java\graalvm-ce-java19-22.3.0\bin\java.exe</executable>
                            <mainClass>src/main/java/adianov/sergei/covidrisk/MainApp.java</mainClass>
                            <launcher>app</launcher>
                            <jlinkZipName>app</jlinkZipName>
                            <jlinkImageName>app</jlinkImageName>
                            <noManPages>true</noManPages>
                            <stripDebug>true</stripDebug>
                            <noHeaderFiles>true</noHeaderFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

Describe the issue
Hello! I'm using GraalVM and IntelliJ IDEA. When I'm trying to build my project via IDE it's messaging me:

Error: Unable to detect supported WINDOWS native software development toolchain.
Querying with command ''C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe'' prints:
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception

Then, I tried to compile native-image via console, x64 Native Tools Command Promts for VS 2022 it says: Error: JavaFX runtime components are missing, and are required to run this application and honestly, I don;t know why I can't solve it, but I can't

Steps to reproduce the issue
Please include both build steps as well as run steps

https://github.com/HeartOfGlass404/COVID-Risk – my project
via console I'm following the guide (typing 1)mvn clean package; 2) mvn -Pnative -Dagent exec:exec@java-agent) and on the 2-nd step it gives me "JavaFX missing" error
via IntelliJ I'm just simply pushing "run" button, my VM options: "D:\Java\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml -H:-CheckToolchain
CLI options: --module-path D:\Java\javafx-sdk-19\lib --add-modules javafx.fxml,javafx.controls,javafx.graphics
Describe GraalVM and your environment:

GraalVM version – 19
JDK major version: 19
OS: Windows 10
Architecture: x64
More details

IntelliJ Trace:

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< adianov.sergei:COVID-Risk >----------------------
[INFO] Building COVID-Risk 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ COVID-Risk ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ COVID-Risk ---
[WARNING] *********************************************************************************************************************************************************************
[WARNING] * Required filename-based automodules detected: [commons-math3-3.6.1.jar, SparseBitSet-1.2.jar]. Please don't publish this project to a public artifact repository! *
[WARNING] *********************************************************************************************************************************************************************
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ COVID-Risk ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Desktop\COVID-Risk\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ COVID-Risk ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ COVID-Risk ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ COVID-Risk ---
[INFO]
[INFO] --- native-maven-plugin:0.9.18:compile-no-fork (default) @ COVID-Risk ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Executing: C:\Users\Sergei.jdks\graalvm-ce-19\bin\native-image.cmd https://github.com/target\tmp\native-image-18324928757939665749.args
���⥬� �� 㤠���� ���� 㪠����� ����.
GraalVM Native Image: Generating 'Covid-risk' (executable)...
[1/7] Initializing... (0,0s @ 0,19GB)
0,5s (6,3% of total time) in 11 GCs | Peak RSS: 0,85GB | CPU load: 2,91

Failed generating 'Covid-risk' after 6,5s.
Error: Unable to detect supported WINDOWS native software development toolchain.
Querying with command ''C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe'' prints:

Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.958 s
[INFO] Finished at: 2023-01-11T22:55:47+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.18:compile-no-fork (default) on project COVID-Risk: Execution of C:\Users\Sergei.jdks\graalvm-ce-19\bin\native-image.cmd https://github.com/target\tmp\native-image-18324928757939665749.args returned non-zero result -> [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:https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

Console trace: Finished generating 'Covid-risk' in 48,1s.
[INFO]
[INFO] --- maven-assembly-plugin:3.3.0:single (default) @ COVID-Risk ---
[WARNING] Failed to build parent project for org.openjfx:javafx-controls:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-controls:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-graphics:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-graphics:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-base:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-base:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-fxml:jar:19-ea+7
[WARNING] Failed to build parent project for org.openjfx:javafx-fxml:jar:19-ea+7
[INFO] Building jar: D:\Desktop\COVID-Risk\target\COVID-Risk-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.996 s
[INFO] Finished at: 2023-01-11T22:29:14+03:00
[INFO] ------------------------------------------------------------------------

D:\Desktop\COVID-Risk> mvn -Pnative -Dagent exec:exec@java-agent
[INFO] Scanning for projects...
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO]
[INFO] ---------------------< adianov.sergei:COVID-Risk >----------------------
[INFO] Building COVID-Risk 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:exec (java-agent) @ COVID-Risk ---
Error: JavaFX runtime components are missing, and are required to run this application
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
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:294)
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:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
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: 1.129 s
[INFO] Finished at: 2023-01-11T22:29:48+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (java-agent) on project COVID-Risk: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [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:https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@HeartOfGlass404 HeartOfGlass404 added the bug Something isn't working label Jan 12, 2023
@loiclefevre
Copy link

You didn't initialize the Visual Studio environnement variables. Check Windows prerequisites https://www.graalvm.org/22.0/reference-manual/native-image/#prerequisites

And in the linked medium blog post, don't forget the step:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants