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

Unable to build Native Image of CLI #1469

Closed
sdelamo opened this issue Oct 10, 2022 · 5 comments
Closed

Unable to build Native Image of CLI #1469

sdelamo opened this issue Oct 10, 2022 · 5 comments
Labels
type: bug Something isn't working

Comments

@sdelamo
Copy link
Contributor

sdelamo commented Oct 10, 2022

Checkout branch interactive-prompt

Run

sdk use java 22.2.r11-grl
./gradlew micronaut-cli:build       
native-image --no-fallback -cp starter-cli/build/libs/micronaut-cli-*-all.jar

it fails with:

Fatal error: java.lang.IllegalAccessError: class io.micronaut.buffer.netty.NettyFeature (in unnamed module @0x33eb0d4) cannot access class com.oracle.svm.core.jdk.SystemPropertiesSupport (in module org.graalvm.nativeimage.builder) because module org.graalvm.nativeimage.builder does not export com.oracle.svm.core.jdk to unnamed module @0x33eb0d4
	at io.micronaut.buffer.netty.NettyFeature.beforeAnalysis(NettyFeature.java:66)

See:

https://github.com/micronaut-projects/micronaut-core/blob/3.7.x/buffer-netty/src/main/java/io/micronaut/buffer/netty/NettyFeature.java#L66

Any idea @yawkat ?

@sdelamo sdelamo added the type: bug Something isn't working label Oct 10, 2022
@timyates
Copy link
Contributor

If we change starter-cli/src/main/resources/META-INF/native-image/io.micronaut.starter.cli/micronaut-starter-cli/native-image.properties to:

Args = -H:Name=mn \
       -H:Class=io.micronaut.starter.cli.MicronautStarter \
        --initialize-at-build-time=picocli.CommandLine$Help$Ansi

And add the export to the native-image command:

native-image --add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED --no-fallback -cp starter-cli/build/libs/micronaut-cli-*-all.jar

Then it works, but I have no idea why we need this change...

@alvarosanchez
Copy link
Member

Looks to me like micronaut-projects/micronaut-gradle-plugin#507

But it's strange since that PR was shipped in 3.5.1 and starter is already using 3.6.2 🤔

@melix
Copy link
Contributor

melix commented Oct 11, 2022

I was confused, because I thought you were using the Gradle plugin to build the native image, but you are not: you are using native-image from CLI, so it's normal that you have to add the --add-exports which the Gradle plugin does by default.

@alvarosanchez
Copy link
Member

🤯

I missed that part too

@sdelamo
Copy link
Contributor Author

sdelamo commented Dec 26, 2022

I no longer know if it applies.

@sdelamo sdelamo closed this as completed Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants