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

Creating native image with Dockerfile.native fails #6260

Closed
shibukawa opened this issue Feb 21, 2023 · 5 comments
Closed

Creating native image with Dockerfile.native fails #6260

shibukawa opened this issue Feb 21, 2023 · 5 comments
Assignees
Labels
3.x Issues for 3.x version branch archetypes bug Something isn't working native-image P2

Comments

@shibukawa
Copy link

Environment Details

  • Helidon Version: 3.1.1
  • Helidon SE and Helidon MP
  • JDK version: java17-22.3.0
  • OS: macOS 13.2.1
  • Docker version (if applicable): Docker Desktop 4.16.2 (95914)

Problem Description

I tried to build docker image with Dockerfile.native, but it fails with the following error. The project is default state of quickstart created by helidon CLI. I hope build finished successfully.

#12 17.83 [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ quickstart-se ---
#12 17.83 [WARNING] JAR will be empty - no content was marked for inclusion!
#12 17.83 [INFO] ------------------------------------------------------------------------
#12 17.83 [INFO] BUILD FAILURE
#12 17.83 [INFO] ------------------------------------------------------------------------
#12 17.83 [INFO] Total time:  17.157 s
#12 17.83 [INFO] Finished at: 2023-02-21T12:37:18Z
#12 17.83 [INFO] ------------------------------------------------------------------------
#12 17.84 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar (default-jar) on project quickstart-se: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [Help 1]
#12 17.84 [ERROR] 
#12 17.84 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
#12 17.84 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
#12 17.84 [ERROR] 
#12 17.84 [ERROR] For more information about the errors and possible solutions, please read the following articles:
#12 17.84 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
------
executor failed running [/bin/sh -c mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip]: exit code: 1

The stacktrace is here:

#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
#12 19.85     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
#12 19.85     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
#12 19.85     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
#12 19.85     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
#12 19.85     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
#12 19.85     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
#12 19.85     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
#12 19.85     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
#12 19.85     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
#12 19.85     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
#12 19.85     at java.lang.reflect.Method.invoke (Method.java:568)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
#12 19.85 Caused by: org.apache.maven.plugin.MojoExecutionException: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them.
#12 19.85     at org.apache.maven.plugins.jar.AbstractJarMojo.execute (AbstractJarMojo.java:265)
#12 19.85     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions (MojoExecutor.java:355)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#12 19.85     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
#12 19.85     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
#12 19.85     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
#12 19.85     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
#12 19.85     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
#12 19.85     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
#12 19.85     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
#12 19.85     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
#12 19.85     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
#12 19.85     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
#12 19.85     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
#12 19.85     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
#12 19.85     at java.lang.reflect.Method.invoke (Method.java:568)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
#12 19.85     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Steps to reproduce

  1. Create project by using helidon init. Options are default except flavor select. I tried both Helidon SE and Helidon MP.
  2. Execute docker build -f Dockerfile.native .
@romain-grecourt
Copy link
Contributor

A workaround is to remove -Pnative-image -Dnative.image.skip from the first RUN.

@romain-grecourt romain-grecourt added bug Something isn't working native-image 3.x Issues for 3.x version branch archetypes labels Feb 21, 2023
@shibukawa
Copy link
Author

Thank you. First RUN finished successfully. But I got another error at second RUN:

#14 45.86  Version info: 'GraalVM 22.3.0 Java 17 CE'
#14 45.86  Java version info: '17.0.5+8-jvmci-22.3-b08'
#14 45.86  C compiler: gcc (redhat, aarch64, 11.3.1)
#14 45.86  Garbage collector: Serial GC
#14 45.86  2 user-specific feature(s)
#14 45.86  - io.helidon.integrations.graal.mp.nativeimage.extension.WeldFeature
#14 45.86  - io.helidon.integrations.graal.nativeimage.extension.HelidonReflectionFeature
#14 45.96 2023.02.22 01:19:54 INFO io.helidon.common.LogConfig Thread[main,5,main]: Logging at initialization configured using classpath: /logging.properties
#14 77.20 [2/7] Performing analysis...  [*]                                                                       (30.9s @ 2.33GB)
#14 77.20   15,002 (90.48%) of 16,581 classes reachable
#14 77.22   19,824 (61.74%) of 32,110 fields reachable
#14 77.33   60,742 (52.69%) of 115,273 methods reachable
#14 77.33    1,003 classes,   563 fields, and 6,427 methods registered for reflection
#14 77.33        2 native libraries: m, stdc++
#14 77.34 
#14 77.34 Error: Classes that should be initialized at run time got initialized during image building:
#14 77.34  me.shibu.mp.quickstart.SimpleGreetResource$Proxy$_$$_WeldClientProxy was unintentionally initialized at build time. To see why me.shibu.mp.quickstart.SimpleGreetResource$Proxy$_$$_WeldClientProxy got initialized use --trace-class-initialization=me.shibu.mp.quickstart.SimpleGreetResource$Proxy$_$$_WeldClientProxy
#14 77.34 me.shibu.mp.quickstart.GreetResource$Proxy$_$$_WeldClientProxy was unintentionally initialized at build time. To see why me.shibu.mp.quickstart.GreetResource$Proxy$_$$_WeldClientProxy got initialized use --trace-class-initialization=me.shibu.mp.quickstart.GreetResource$Proxy$_$$_WeldClientProxy
#14 77.34 me.shibu.mp.quickstart.GreetingProvider$Proxy$_$$_WeldClientProxy was unintentionally initialized at build time. To see why me.shibu.mp.quickstart.GreetingProvider$Proxy$_$$_WeldClientProxy got initialized use --trace-class-initialization=me.shibu.mp.quickstart.GreetingProvider$Proxy$_$$_WeldClientProxy
#14 77.34 To see how the classes got initialized, use --trace-class-initialization=me.shibu.mp.quickstart.SimpleGreetResource$Proxy$_$$_WeldClientProxy,me.shibu.mp.quickstart.GreetResource$Proxy$_$$_WeldClientProxy,me.shibu.mp.quickstart.GreetingProvider$Proxy$_$$_WeldClientProxy
#14 77.34 Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
#14 77.34 ------------------------------------------------------------------------------------------------------------------------
#14 77.34                         4.6s (12.9% of total time) in 25 GCs | Peak RSS: 3.22GB | CPU load: 3.35
#14 77.34 ========================================================================================================================
#14 77.34 Failed generating 'quickstart-mp' after 35.2s.
#14 78.45 Error: Image build request failed with exit status 1

Stacktrace:

#14 74.75 [ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.16:compile (build-native-image) on project quickstart-mp: Execution of /opt/graalvm-ce-java17-22.3.0/bin/native-image @target/tmp/native-image-2947829071060964417.args returned non-zero result -> [Help 1]
#14 74.75 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.16:compile (build-native-image) on project quickstart-mp: Execution of /opt/graalvm-ce-java17-22.3.0/bin/native-image @target/tmp/native-image-2947829071060964417.args returned non-zero result
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
#14 74.75     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
#14 74.75     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
#14 74.75     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
#14 74.75     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
#14 74.75     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
#14 74.75     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
#14 74.75     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
#14 74.75     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
#14 74.75     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
#14 74.75     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
#14 74.75     at java.lang.reflect.Method.invoke (Method.java:568)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
#14 74.75 Caused by: org.apache.maven.plugin.MojoExecutionException: Execution of /opt/graalvm-ce-java17-22.3.0/bin/native-image @target/tmp/native-image-2947829071060964417.args returned non-zero result
#14 74.75     at org.graalvm.buildtools.maven.AbstractNativeImageMojo.buildImage (AbstractNativeImageMojo.java:403)
#14 74.75     at org.graalvm.buildtools.maven.NativeCompileNoForkMojo.execute (NativeCompileNoForkMojo.java:96)
#14 74.75     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
#14 74.75     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
#14 74.75     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
#14 74.75     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
#14 74.75     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
#14 74.75     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
#14 74.75     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
#14 74.75     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
#14 74.75     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
#14 74.75     at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
#14 74.75     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
#14 74.75     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
#14 74.75     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
#14 74.75     at java.lang.reflect.Method.invoke (Method.java:568)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
#14 74.75     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@romain-grecourt
Copy link
Contributor

I can confirm that this is a bug (most likely introduced by #5308).

If the application uses a package that does not start with io.helidon it fails with the reported error.
As a workaround you can configure the native-maven-plugin like this:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
    <configuration>
        <buildArgs>--initialize-at-build-time=com.acme</buildArgs>
    </configuration>
</plugin>

Replace com.acme with your package.


You will also need to change the runtime base image (the 2nd stage):

FROM ghcr.io/oracle/oraclelinux:9-slim

I'll file separate issues for --initialize-at-build-time and the runtime base image ; we will track the prime staging issue you faced initially here.

@shibukawa
Copy link
Author

Your solution works fine. Thank you!

@shibukawa
Copy link
Author

I close this issue because #6283 and #6284 inherit this issue's root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues for 3.x version branch archetypes bug Something isn't working native-image P2
Projects
Archived in project
Development

No branches or pull requests

3 participants