Unable to create native image with micronaut-http-client and jansi
envgap__micronaut-projects__micronaut-core-5328
Original GitHub issue ↗Opened 2021-04-27
01 / FAILURE SIGNATURE
As reported upstream
Fatal error:java.lang.NoClassDefFoundError
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
pom.xml- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
micronaut-projects/micronaut-core #5328 · read the original issue
I'm trying to build an interactive shell application with Micronaut and Jansi but i'm unable to compile it as a GraalVM native image. The compilation fails when both the `jansi` and `micronaut-http-client` dependency are on the classpath. The `jansi` dependency doesn't contain any links to the project which contains the class in the exception (netty-tcnative, io.netty.internal.tcnative.SSLPrivateKeyMethod) as far as I know but does use JNI which might trigger the error in Micronaut or Netty. @ilopmar do you have any idea what could cause this error or how to make GraalVM show which class refers to to the mentioned class? ### Task List - [x] Steps to reproduce provided - [x] Stacktrace (if present) provided - [ ] Example that reproduces the problem uploaded to Github - [x] Full description of the issue provided (see below) ### Steps to Reproduce 1. Create a new Micronaut CLI app (`mn create-cli-app --build=maven --lang=java --test=junit --features=graalvm,jib,logback,mockito,shade my.package.app`) 2. Build native image (`./mvnw clean package -Dpackaging=docker-native -Pgraalvm`) 3. Add `jansi` dependency (`org.fusesource.jansi:jansi:2.3.2`, https://github.com/fusesource/jansi/) 4. Build native image (`./mvnw clean package -Dpackaging=docker-native -Pgraalvm`) 5. Change `micronaut-http-client` dependency from `test` to `compile` scope 6. Building native image will fail (`./mvnw clean package -Dpackaging=docker-native -Pgraalvm`) ### Expected Behaviour The GraalVM native image compiler should succeed in creating a native image. This is the case when one of the `micronaut-http-client` or `jansi` dependencies are removed. ### Actual Behaviour The GraalVM native image compiler fails with an exception: ``` Fatal error:java.lang.NoClassDefFoundError at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:603) at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006) at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:499) at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:370) at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:531) at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119) at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:568) Caused by: java.lang.NoClassDefFoundError: io/netty/internal/tcnative/SSLPrivateKeyMethod at jdk.internal.vm.ci/jdk.v
04 / LABELS
Labels from the report text only; not yet run
securityLabel rules and the text that matched
[
{
"category": "security",
"rule": "issue.security_keyword",
"source": "issue_body",
"excerpt": "e when one of the `micronaut-http-client` or `jansi` dependencies are removed.\r\n\r\n### Actual Behaviour\r\n\r\nThe GraalVM native image compiler fails with an exception:\r\n\r\n```\r\nFata"
}
]Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy reproduction is generic install-only; match the actual issue failure before admission.