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

Micronaut 1.3.5 and Netty 4.1.48.Final Graal Native Image Creation Failure #3341

Closed
3 of 4 tasks
brianwyka opened this issue May 26, 2020 · 11 comments
Closed
3 of 4 tasks
Assignees

Comments

@brianwyka
Copy link
Contributor

brianwyka commented May 26, 2020

Getting errors generating native image for micronaut 1.3.5 with netty Netty 4.1.48.Final.

Please see attached native-image.zip for details about micronaut and third party native image configuration.
native-image.zip

Some possibly related issues:

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Build Application
  2. Run native image command on shaded jar
native-image -cp app.jar --no-server

native-image.properties

Args = -H:Name=app \
    -H:IncludeResources=logback.xml|application.yml \
    -H:Class=org.example.App \
    -H:+TraceClassInitialization \
    -H:+ReportExceptionStackTraces

Expected Behaviour

The native image should be created without any errors during building.

Actual Behaviour

When trying to create the native image, receive the following exceptions:

Warning: class initialization of class io.micronaut.http.bind.binders.ContinuationArgumentBinder failed with exception java.lang.NoClassDefFoundError: kotlin/TypeCastException. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.micronaut.http.bind.binders.ContinuationArgumentBinder to explicitly request delayed initialization of this class.
Warning: class initialization of class io.micronaut.http.bind.binders.ContinuationArgumentBinder$Companion failed with exception java.lang.NoClassDefFoundError: kotlin/TypeCastException. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.micronaut.http.bind.binders.ContinuationArgumentBinder$Companion to explicitly request delayed initialization of this class.
[payload-archhive-service-app:48388]     analysis: 100,172.49 ms,  5.69 GB
Error: Classes that should be initialized at run time got initialized during image building:
 io.netty.channel.DefaultFileRegion the class was requested to be initialized at run time (subtype of io.netty.util.AbstractReferenceCounted). To see why io.netty.channel.DefaultFileRegion got initialized use -H:+TraceClassInitialization
io.netty.util.AbstractReferenceCounted the class was requested to be initialized at run time (from the command line). To see why io.netty.util.AbstractReferenceCounted got initialized use -H:+TraceClassInitialization

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 io.netty.channel.DefaultFileRegion the class was requested to be initialized at run time (subtype of io.netty.util.AbstractReferenceCounted). To see why io.netty.channel.DefaultFileRegion got initialized use -H:+TraceClassInitialization
io.netty.util.AbstractReferenceCounted the class was requested to be initialized at run time (from the command line). To see why io.netty.util.AbstractReferenceCounted got initialized use -H:+TraceClassInitialization

        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:518)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:720)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:538)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:451)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image build request failed with exit status 1

Environment Information

  • Operating System: Linux (Ubuntu 20.0.4)
  • Micronaut Version: 1.3.5
  • Micronaut Kafka Version: 2.0.0
  • JDK Version: 1.8
  • Maven Version: 3.6.1
@ilopmar ilopmar self-assigned this May 26, 2020
@ilopmar
Copy link
Contributor

ilopmar commented May 26, 2020

@brianwyka do you have a test application for this? We have a basic test application for this and it works properly for both 1.3.x and master.
Please take a look at https://github.com/micronaut-graal-tests/micronaut-basic-app

@msandy10
Copy link

I am also getting the same error while building graalvm native image

  • micronautVersion=1.3.5
  • awssdkVersion=2.12.0
  • native-image.properties as below
    Args = -H:IncludeResources=logback.xml|application.properties|git.properties \ -H:Name=server \ -H:Class=io.micronaut.function.aws.runtime.MicronautLambdaRuntime \ -H:+PrintClassInitialization \ -H:+TraceClassInitialization \ -H:Log=registerResource \ -H:+ReportExceptionStackTraces \ -H:EnableURLProtocols=http \ -H:-AllowVMInspection \ -H:DynamicProxyConfigurationFiles=dynamic-proxies.json \ --allow-incomplete-classpath \ --initialize-at-build-time=software.amazon.awssdk.protocols.core.StringToValueConverter,org.apache.http.conn.routing.HttpRoute,org.apache.http.protocol.HttpContext,org.apache.http.HttpClientConnection,org.apache.http.pool.ConnPoolControl,org.apache.http.conn.HttpClientConnectionManager,org.apache.http.conn.ConnectionRequest \ --initialize-at-run-time=io.micronaut.http.bind.binders.ContinuationArgumentBinder
Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature
78 | [server:110]     analysis:  50,591.03 ms
79 | Error: Classes that should be initialized at run time got initialized during image building:
80 | io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted
81 | com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
82 | io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted
83 | at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
84 | at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:494)
85 | at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:188)
86 | at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:711)
87 | at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
88 | at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:711)
89 | at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:526)
90 | at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:444)
91 | at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
92 | at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
93 | at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
94 | at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
95 | at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
96 | Error: Image build request failed with exit status 1
97

@graemerocher
Copy link
Contributor

@msandy10 Your error seems related to using AWS SDK 2.

We are soon going to be releasing GraalVM native image support for the AWS SDK 2. You can see snapshot docs here https://micronaut-projects.github.io/micronaut-aws/snapshot/guide/#sdkv2

Will be in the Micronaut 2.0 RC1 out in the next couple of weeks.

@msandy10
Copy link

msandy10 commented May 26, 2020

While cross-checking found that our other services using Micronaut(1.3.4) and AWS SDK V2(SSM, Lambda&S3) working fine, This function also have same version dependencies and same native-image.properties but We have added elastic search client dependencies as given
`

  • compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '6.7.1'
  • compile group: 'org.elasticsearch', name: 'elasticsearch', version: '6.7.1'
  • compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: '6.7.1'
    `
    Note: We are not Micronauts-elastic search 1.2 because it doesn't support ElasticSearch 6.X

look like Elastic Search Client jar has created native build issue, do i need to include any native-image.properties to solve this issue.

Are we getting AWS SDK V2 support in Micronaut 1.3.X ?

Codebase :- my-app-elasticsearch.zip

@brianwyka
Copy link
Contributor Author

Will try to get an example of this. Need to flatten some of our structure to produce an example.

@brianwyka
Copy link
Contributor Author

@ilopmar, do you have any maven projects for graal testing?

@ilopmar
Copy link
Contributor

ilopmar commented May 29, 2020

@brianwyka No, I don't. You can easily create one using https://micronaut.io/launch/ or with the CLI (Micronaut 2.0.0.M3):

mn create-app mn-graalvm --features=graalvm --build=maven

@msandy10
Copy link

msandy10 commented Jun 5, 2020

Hi @ilopmar,

is there issue to build graal native image with Micronaut 1.3.4 and elasticsearch(6.7.1)? we are geeting following issue while upgrading micronaut(1.1.1) to micronaut(1.3.4)

81 | com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
82 | io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted
83 | at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
84 | at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:494)
85 | at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:188)
86 | at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:711)
87 | at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
88 | at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:711)
89 | at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:526)
90 | at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:444)
91 | at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
92 | at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
93 | at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
94 | at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
95 | at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
96 | Error: Image build request failed with exit status 1

Ref Code :- my-app-elasticsearch.zip

@ilopmar
Copy link
Contributor

ilopmar commented Jun 5, 2020

Another user reported this micronaut-projects/micronaut-elasticsearch#34 with Micronaut 2.0.0.M3 an ElasticSearch 7.6.2. It's not the same error though.

@msandy10
Copy link

msandy10 commented Jun 9, 2020

Above issue with Micronaut 2.0.0.M3, we are getting Issue with Micronnaut(1.3.4) and ElasticSearch(6.7.1). please refer RefCode :- my-app-elasticsearch.zip

@ilopmar
Copy link
Contributor

ilopmar commented Jun 17, 2020

@msandy10 I've added support for Elasticsearch in GraalVM. Please take a look at micronaut-projects/micronaut-elasticsearch#34 (comment).

Please be aware that you need to use implementation("io.micronaut.elasticsearch:micronaut-elasticsearch:2.0.0.RC2") and not the version from the BOM. In next Micronaut version it will be included by default.

I'm closing this issue because it's related to AWS and Elasticsearch and both work with GraalVM. If the problem persist, please open a new issue in the appropriate repository with a test application that reproduces the problem.

@ilopmar ilopmar closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants