Hello, I am having trouble while compiling springboot using maven v3.1.1, the error message is
Fatal error: com.oracle.svm.core.util.VMError$HostedError: Option name "IncludeResourceBundles" has multiple definitions: com.oracle.svm.core.jdk.LocalizationSupport$Options.IncludeResourceBundles and com.oracle.svm.core.jdk.LocalizationFeature$Options.IncludeResourceBundles
at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:66)
at com.oracle.svm.hosted.option.HostedOptionParser.collectOptions(HostedOptionParser.java:88)
at com.oracle.svm.hosted.option.HostedOptionParser.<init>(HostedOptionParser.java:61)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:206)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:454)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:115)
Can someone help me ?
What does your dependencies look like in the Maven pom.xml for Graal related artifacts? Are you sure it's not pulling in outdated/duplicate dependencies?
Thank you for your answer. But I have another problem, I have already followed the steps of issues / 1866. But to no avail :(
[ERROR] Failed to execute goal org.graalvm.nativeimage:native-image-maven-plugin:19.3.1:native-image (default) on project s1-server-pdv-mono-application: Image building on Java 11+ without native-image requires MAVEN_OPTS='--add-exports=java.base/jdk.internal.module=ALL-UNNAMED' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.graalvm.nativeimage:native-image-maven-plugin:19.3.1:native-image (default) on project s1-server-pdv-mono-application: Image building on Java 11+ without native-image requires MAVEN_OPTS='--add-exports=java.base/jdk.internal.module=ALL-UNNAMED'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
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:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Image building on Java 11+ without native-image requires MAVEN_OPTS='--add-exports=java.base/jdk.internal.module=ALL-UNNAMED'
at com.oracle.substratevm.NativeImageMojo.execute (NativeImageMojo.java:255)
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:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
[ERROR]
[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
when trying to create native image
With command - > cd %JAVA_HOME% REM Change to GraalVM root dir
binnative-image.cmd -jar lib\graalvm\svm-driver.jar -H:Path=.\bin REM Build yourself a native-image.exe next to binnative-image.cmd
` Creating library C:\graalvm-ee-java11-19.3.1native-image.lib and object C:\graalvm-ee-java11-19.3.1native-image.exp
net.lib(NetworkInterface.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsnprintf_s referenced in function _snprintf_s
net.lib(NetworkInterface_winXP.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsnprintf_s
net.lib(net_util_md.obj) : error LNK2019: unresolved external symbol __imp___acrt_iob_func referenced in function printf
java.lib(jni_util.obj) : error LNK2001: unresolved external symbol __imp___acrt_iob_func
net.lib(net_util_md.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vfprintf referenced in function _vfprintf_l
java.lib(jni_util.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vfprintf
jvm.lib(JvmFuncs.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vfprintf
net.lib(net_util_md.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsprintf referenced in function _vsnprintf_l
net.lib(NetworkInterface_winXP.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsprintf
jvm.lib(JvmFuncs.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsprintf
java.lib(ProcessImpl_md.obj) : error LNK2019: unresolved external symbol __report_rangecheckfailure referenced in function win32Error
zip.lib(inftrees.obj) : error LNK2001: unresolved external symbol __report_rangecheckfailure
java.lib(ProcessImpl_md.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vswprintf referenced in function _vswprintf_c_l
C:\graalvm-ee-java11-19.3.1native-image.exe : fatal error LNK1120: 6 unresolved externals
at com.oracle.svm.hosted.image.NativeBootImageViaCC.write(NativeBootImageViaCC.java:388)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:652)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1`
Hi I think this might be a windows problem when using the native-image-maven-plugin.
I receive the MAVEN_OPTS error when on windows but packaging the same project on the subsystem for linux does not produce the same error.
@gdoenlen I also ran into this on Arch Linux.
Image building on Java 11+ without native-image requires MAVEN_OPTS='--add-exports=java.base/jdk.internal.module=ALL-UNNAMED'
Solution: https://www.graalvm.org/docs/reference-manual/native-image/#install-native-image
gu install native-image
That's one shitty error message!
Solution: https://www.graalvm.org/docs/reference-manual/native-image/#install-native-image
gu install native-imageThat's one shitty error message!
Thanks this solved my issue.
Sorry, I'm sure I have native-image installed as I conclude from this message when I run "gu install native-image".
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Component Native Image (org.graalvm.native-image) is already installed.
graalvm version is
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
I'm using the corresponding maven plugin
[ERROR] Failed to execute goal org.graalvm.nativeimage:native-image-maven-plugin:20.1.0:native-image (default) on project ruu.io-graalvm-sandbox: Image building on Java 11+ without native-image requires MAVEN_OPTS='--add-exports=java.base/jdk.internal.module=ALL-UNNAMED
Operating system is windows 10.
Any ideas? Thanx.
What's the output of echo %PATH%. Does that PATH have the directory which has native-image binary?
I have the following in my path and you can see, that native-image.exe is in the path:
echo %path%
c:\software\develop\java\graalvm\bin;
... lots of stuff ...
c:\software\develop\java\graalvm\lib\svm\bin
dir %graalvm_home%\lib\svm\bin\nat*.exe
Datentr盲ger in Laufwerk C: ist Local Disk
Volumeseriennummer: 1CFD-CD9B
Verzeichnis von c:\software\develop\java\graalvm\lib\svm\bin
12.06.2020 12:40 13.082.624 native-image.exe
1 Datei(en), 13.082.624 Bytes
0 Verzeichnis(se), 123.392.651.264 Bytes frei
The last path entry points to the directory where native-image.exe resides. There are no other locations with such a file. Everything should be fine regarding path, shouldn't it? Or do you have to see "... lots of stuff ..." (the complete path)?
Thanx for looking over this.
@r-uu for the native-image executable to be found you need to run maven with GraalVM as your JAVA_HOME or set GraalVM as your Maven toolchain for your project (see https://github.com/oracle/graal/commit/cd933db27a27d7aae8c133a0cd43478544675acb).
Sorry for replying so lately. I did a mvn -version and received the following output:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: c:\software\develop\build\maven\bin..
Java version: 11.0.7, vendor: GraalVM Community, runtime: c:\software\develop\java\graalvm
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
That clearly tells me that maven does use graalvm.
And I also tried that maven toolchain. Unfortunately to no avail.
Anything else I could try?
@r-uu I just checked and this is indeed not working anymore on Windows. I will have a look.
Thanks for the bug report!
Never mind. Thanks for looking over that.
@r-uu I found the problem. Until I have a fix you can use the following workaround:
Copy <GRAAVM_HOME>\lib\svm\bin\native-image.exe to <GRAAVM_HOME>\bin. This should be enough for native-image-maven-plugin for find the tool. Sorry for the inconvenience.
Thanks again. Copying native-image.exe changed the behaviour. Now I get an error due to the fact that I rely on dependencies (I control these myself) that are compiled with a more recent jdk version (14). Now I have to figure out if I can downgrade to 11. This will take some time and I will come back to tell if I succeeded.
Ok. I tried some things. I definitely have only one jdk in my environment: graalvm, latest version. I have native-image.exe in
Error: Unable to detect supported WINDOWS native software development toolchain.
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
What can I try next?
@r-uu typically it asks for cl.exe when you haven't initialized the x64 Native Tools Command Prompt in windows.
The error about the native development toolchain seems to imply this.
Check quarkus guide on setting up for native (ctrl-f for windows): https://quarkus.io/guides/building-native-image
Maven asked for a cl.exe. I manually made a copy of native-image.exe to cl.exe in
\bin.
@r-uu cl.exe is the Microsoft C++ compiler. It's a dependency of native-image. Copying of native-image.exe to cl.exe does not solve the problem. Instead as https://github.com/oracle/graal/issues/2151#issuecomment-647808590 already mentioned you need to install the x64 Native Tools Command Prompt that is part of Visual Studio 2017 or later. For more info see https://www.graalvm.org/docs/reference-manual/native-image/ _Prerequisites for Using Native Image on Windows_. To use native-image standalone or via maven with the native-image-maven-plugin you have to run your commands from the x64 Native Tools Command Prompt so that native-image can find cl.exe.
@gdoenlen and @olpaw: Thank you for your patience. I must have been in total despair when I renamed native-image.exe to cl.exe ;)
I followed the instructions for setting up for native and I checked everything once again:
I have a graalvm_home environment variable pointing to the correct graalvm installation directory:
%graalvm_home%\bin\java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
I have the native image tool installed:
%graalvm_home%\bingu install native-image
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Component Native Image (org.graalvm.native-image) is already installed.
I have java_home environment variable pointing to the same directory as graalvm_home:
%java_home%\bin\java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
Now when I run
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Pnative
build fails with
[example:15564] classlist: 13,371.10 ms, 0.94 GB
[example:15564] setup: 1,726.49 ms, 0.94 GB
Error: Unable to detect supported WINDOWS native software development toolchain.
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
I simply do not see what I am missing. Any ideas or suggestions?
BTW: I stripped down my project to a simple hello world app, so I do not expect any problems from my code or dependencies ...
Where am I supposed to put that "-H:+ReportExceptionStackTraces" option?
Now when I run call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Pnative
You have to open the x64 Native Tools Command Prompt.
There to verify you are in the right Command Prompt try
cl
You should see something like
Microsoft (R) C/C++ Optimizing Compiler Version 19.12.25835 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
From inside that Command Prompt you can use native-image.
I had a look at #2480 and installed 20.2.0-dev version on my machine. The native tools command prompt now works and gives the output for cl that you describe. After copying native-image.exe to graalvm\bin I now get a different error:
[example:21384] classlist: 3,639.40 ms, 0.96 GB
[example:21384] setup: 516.71 ms, 0.96 GB
Error: Already registered: java.lang.management.ManagementFactory.newPlatformMXBeanProxy(MBeanServerConnection, String, Class)
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Could not find any hints on google to solve this so far ...
And in case this might be helpful, how and where can I use that ReportExceptionStackTraces?
And in case this might be helpful, how and where can I use that ReportExceptionStackTraces?
Add
<configuration>
<buildArgs>
-H:+ReportExceptionStackTraces
</buildArgs>
</configuration>
to the <plugin> in your pom.xml file. Example for configuring the native-image-maven-plugin can be found at:
https://github.com/graalvm/graalvm-demos/blob/master/native-image-configure-examples/configure-at-buildtime-example/pom.xml#L88..L94
I reinstalled version 20.1.0 and also reinstalled msvs build tools 2017 but this time with an english language pack. As far as I can see this lead to a successful creation of a (trivial) native image for windows 10. I will build upon that and see if I can extend that trivial program to something more interesting. Thanks a lot for all the help!
BTW, it worked with the maven plugin in this environment ...
One more observation: if the build tools are not initialised maven plugin does not work (it does not initialise build tools automatically). I create a shell with a .cmd file, that sets everything I need, build tools included. With that maven plugin throws warnings but succeeds.
@r-uu are you able to share your script which does this initialization? Just curious as I ran into this just now while trying to build on GitHub Actions. Once I copied native-image.exe from lib/svm/bin to /bin it works. I'm curious how you worked around this.
@collinpeters the relevant part is just a call to vcvars64.bat:
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
As you can see I updated to Visual Studio 2019 meanwhile. However, in the meantime I gave up with building a native image because I tried hard but could not find a way to get such basic stuff as log4j running :(
Most helpful comment
Solution: https://www.graalvm.org/docs/reference-manual/native-image/#install-native-image
gu install native-imageThat's one shitty error message!