Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Unable to execute NativeImage #234

Open
joaquinodz opened this issue Nov 19, 2019 · 11 comments
Open

Unable to execute NativeImage #234

joaquinodz opened this issue Nov 19, 2019 · 11 comments

Comments

@joaquinodz
Copy link

joaquinodz commented Nov 19, 2019

What happened?

I've been trying to generate a native image on my proyect but after exectuting the nativeImage task y get this error:

> Task :desktop:nativeImage FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':desktop:nativeImage'.
> Process 'command 'cmd.exe'' finished with non-zero exit value 255

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

NOTE: Using Windows OS, Gradle 5.6.4.

@Iltotore
Copy link

Same error. The stacktrace just indicate that the problem is at NativeImageTask line 67.

@sugoidogo
Copy link

sugoidogo commented Jan 28, 2020

--info reveals a cmd script referencing "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
this seems to be from the Windows 7 SDK requirement referenced at #141, in this comment
I have been unable to install the Windows 7 SDK on my Windows 10 machine due to a conflict with "preview SDK versions".
This MSDN post details a workaround.
After that, native image succeeds.

@sugoidogo
Copy link

I would add following to README.md:

Preconditions when using on Windows

GraalVM needs the Microsoft Windows SDK for Windows 7 and .NET Framework 4 as well as the C compilers from KB2519277.

You can install it using chocolatey:

choco install windows-sdk-7.1 kb2519277

@assimbly
Copy link

I have the same "non-zero exit value 255" error. Which basicly says that my Java application can't run. If there
is a dependency on the OS SDK (specific version) for the "nativeImage" of the Graal plugin then I agree that it would be good to add that to the readme.

Here is the SDK Archive for Windows: https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/

I installed the SDK but still have this error. This maybe because I'm using Spring Boot. The main class is the start class which is configured in Gradle like this:

springBoot {
mainClassName = 'org.myorg.main.myApp'
}

However the main class (in the Manifest) is org.springframework.boot.loader.JarLauncher. It doesn't matter whichI designate (the start or the main class) it fails with the same error.

@sugoidogo
Copy link

@assimbly my comments list multiple options for installers that fix your issue. Please read before you post.

@assimbly
Copy link

assimbly commented Mar 24, 2020

What do you mean exactly with that comment? I have used the command line:

choco install windows-sdk-7.1 kb2519277

Everything like SDK7.1 .Net4 and C compilers are installed (no warning/errors in the installer). Because I have multiple SDKs I used the following command:

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86

However I still have the same error message (ERROR: The system was unable to find the specified registry key or value. ♀Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.
1. Targeting Windows 7 x86 Release). There is an article about that:

https://stackoverflow.com/questions/22188919/windows-sdk-registry-variable-not-found

When checking the SDK directory and regedit value everything seems to be OK.

@sugoidogo
Copy link

sugoidogo commented Mar 24, 2020

Your original comment does not mention any of the steps I posted and has a small amount of incorrect/redundant information. If you followed the previous instructions then please include that in your post so people don't think you're ignoring them.

This plugin calls the correct setenv by itself, regardless of how many sdks you have installed, because the path is hardcoded. If you are calling setenv before gradle nativeimage then that may be your issue. You can also try running with --info or the other flags suggested by Gradle when a command fails in order to diagnose. Either way, it sounds like you're having a separate issue. If you need more help, please open a new issue.

@adityathakur-ast
Copy link

Hey everyone, I was trying to use this plugin on Windows 10, and I get the same error.

The syntax of the command is incorrect.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeImage'.
> Process 'command 'cmd.exe'' finished with non-zero exit value 255

Stacktrace:

Caused by: org.gradle.process.internal.ExecException: Process 'command 'cmd.exe'' finished with non-zero exit value 255
	at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:417)
	at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:38)
	at org.gradle.process.internal.DefaultExecActionFactory.exec(DefaultExecActionFactory.java:152)
	at org.gradle.api.internal.project.DefaultProject.exec(DefaultProject.java:1135)
	at com.palantir.gradle.graal.NativeImageTask.nativeImage(NativeImageTask.java:67)

Any help is appreciated.

@sugoidogo
Copy link

sugoidogo commented Apr 12, 2020

@adityathakur-ast have you tried this: #234 (comment) , #234 (comment)
If you have, please mention that when you ask for help.
If you haven't, please read the thread before asking for help.

@adityathakur-ast
Copy link

Hi @josephsmendoza

Apologies for not being clear earlier, I have gone through your comments, but I would like to avoid a work-around, so I used "Ubuntu on Windows" which seems to work at this particular step but fails at later stage due to lack of support for graalvm 19.3+ versions.

Just to be more clear, I have checked that there is an existing PR for that, if possible, I would like to help with two things here :

  1. Windows 10 support without workaround, if possible please guide me a direction where should I look.
  2. Adding support for recent graalvm version.

@sugoidogo
Copy link

sugoidogo commented Apr 12, 2020

Let me clarify, in case it wasn't obvious, that the Windows 7 SDK is not a workaround. It is a requirement for building a native image on windows with this plugin. You could install a newer Windows SDK and GraalVM, call setenv or vcvars, and then run native-image manually. But for this plugin to work (currently) you need the Windows 7 SDK. You will only need the workaround on a Windows 10 machine if the Windows 7 SDK fails to install.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants