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

Quarkus Native build with Mandrel fails due to AWT Toolkit, AWT Color and AWTAccessor #25034

Closed
onrclk opened this issue Apr 20, 2022 · 2 comments
Labels

Comments

@onrclk
Copy link

onrclk commented Apr 20, 2022

i'm trying to build my project api with native using mandrel distribution 22.0 version like following. i've tried so many things like different Mandrel versions. ( 20.3 , 21.3) Unfortunately none of them have been worked so far. i'm still getting same exceptions although AWT libray is not used directly in project. on native build process. i'm using files like suggested on following issue #19789.

quarkus.native.container-build=true
quarkus.native.native-image-xmx=8g
quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:22.0-java11

quarkus.native.additional-build-args=-H:ReflectionConfigurationFiles=reflect-config.json,
-H:ResourceConfigurationFiles=resources-config.json,
--initialize-at-run-time=
java.awt.Toolkit\,
sun.awt.AWTAccessor\,
java.awt.Color\,

--trace-class-initialization=
java.awt.Toolkit\,
sun.awt.AWTAccessor\,
java.awt.Color\

pom.xml

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-rest-client-jaxb</artifactId>
</dependency>

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-amazon-lambda-rest</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.resteasy</groupId>
  <artifactId>resteasy-multipart-provider</artifactId>
</dependency>

<dependency>
  <groupId>io.rest-assured</groupId>
  <artifactId>rest-assured</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.apache.poi</groupId>
  <artifactId>poi</artifactId>
  <version>${apache.poi.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.poi</groupId>
  <artifactId>poi-ooxml</artifactId>
  <version>${apache.poi.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>${commons.lang3.version}</version>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-amazon-s3</artifactId>
</dependency>
<dependency>
  <groupId>software.amazon.awssdk</groupId>
  <artifactId>url-connection-client</artifactId>
</dependency>
<dependency>
  <groupId>software.amazon.awssdk</groupId>
  <artifactId>sfn</artifactId>
</dependency>

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk-lambda</artifactId>
  <version>1.12.7</version>
</dependency>

Expected behavior

No response

Actual behavior

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 22.0.0.2-Final Mandrel Distribution (Java Version 11.0.14+9)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm -v internal-api-1.3.5-SNAPSHOT-native-
ge-source-jar:/project:z --name build-native-tjJBu quay.io/quarkus/ubi-quarkus-mandrel:22.0-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-DCoordinatorEnvironmentBean.transactionStatu
nagerEnable=false -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegate
tory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -H:-ParseOnce -H:ReflectionC
igurationFiles=reflect-config.json -H:ResourceConfigurationFiles=resources-config.json --initialize-at-run-time=java.awt.Toolkit,sun.awt.AWTAccessor,java.awt.Color,--trace-class-initialization=java.awt.Toolki
un.awt.AWTAccessor,java.awt.Color -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces
-Xmx8g -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace internal-api-1.3.5-SNAPSHOT-runner -jar internal-api-1.3.5-SNAPSHOT-runner.jar

GraalVM Native Image: Generating 'internal-api-1.3.5-SNAPSHOT-runner'...

[1/7] Initializing... (22.1s @ 0.30GB)
Version info: 'GraalVM 22.0.0.2-Final Java 11 Mandrel Distribution'
7 user-provided feature(s)

  • io.quarkus.awt.runtime.graal.AwtFeature
  • io.quarkus.caffeine.runtime.graal.CacheConstructorsAutofeature
  • io.quarkus.jdbc.postgresql.runtime.graal.SQLXLMFeature
  • io.quarkus.runner.AutoFeature
  • io.quarkus.runtime.graal.ResourcesFeature
  • org.hibernate.graalvm.internal.GraalVMStaticAutofeature
  • org.hibernate.graalvm.internal.QueryParsingSupport
    The bundle named: messages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
    [2/7] Performing analysis... [*] (61.2s @ 2.94GB)
    09:45:43,408 INFO [org.hib.Version] HHH000412: Hibernate ORM core version 1.3.5-SNAPSHOT
    09:45:43,560 INFO [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
    09:45:43,599 INFO [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect
    09:45:54,403 INFO [org.jbo.threads] JBoss Threads version 3.4.2.Final
    To see how the classes got initialized, use --trace-class-initialization=sun.awt.AWTAccessor,java.awt.Toolkit,java.awt.Color
    22,780 (90.78%) of 25,093 classes reachable
    33,865 (69.39%) of 48,801 fields reachable
    119,909 (70.47%) of 170,147 methods reachable
    580 classes, 1,079 fields, and 3,123 methods registered for reflection

Error: Classes that should be initialized at run time got initialized during image building:
sun.awt.AWTAccessor the class was requested to be initialized at run time (from the command line with 'sun.awt.AWTAccessor'). To see why sun.awt.AWTAccessor got initialized use --trace-class-initialization=s
awt.AWTAccessor
java.awt.Toolkit the class was requested to be initialized at run time (from the command line with 'java.awt.Toolkit'). To see why java.awt.Toolkit got initialized use --trace-class-initialization=java.awt.To
it
java.awt.Color the class was requested to be initialized at run time (from the command line with 'java.awt.Color'). To see why java.awt.Color got initialized use --trace-class-initialization=java.awt.Color

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
sun.awt.AWTAccessor the class was requested to be initialized at run time (from the command line with 'sun.awt.AWTAccessor'). To see why sun.awt.AWTAccessor got initialized use --trace-class-initialization=s
awt.AWTAccessor
java.awt.Toolkit the class was requested to be initialized at run time (from the command line with 'java.awt.Toolkit'). To see why java.awt.Toolkit got initialized use --trace-class-initialization=java.awt.To
it
java.awt.Color the class was requested to be initialized at run time (from the command line with 'java.awt.Color'). To see why java.awt.Color got initialized use --trace-class-initialization=java.awt.Color

    at com.oracle.svm.core.util.UserError.abort(UserError.java:73)                                                                                                                                          
    at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:555)                                                       
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:167)                                                                             
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$10(NativeImageGenerator.java:704)                                                                                              
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:74)                                                                                                                          
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$11(NativeImageGenerator.java:704)                                                                                              
    at com.oracle.graal.pointsto.PointsToAnalysis.runAnalysis(PointsToAnalysis.java:755)                                                                                                                    
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:702)                                                                                                        
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:537)                                                                                                                      
    at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:494)                                                                                                                        
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:426)                                                                                                     
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:587)                                                                                                          
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:126)                                                                                                           
    at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:617)                                                                                                  

                    9.1s (10.7% of total time) in 40 GCs | Peak RSS: 5.16GB | CPU load: 7.83                                                                                                                

Output of java -version

openjdk version "11.0.11" 2021-04-20

GraalVM version (if different from Java)

22.0.0.2-Final Mandrel Distribution (Java Version 11.0.14+9)

Quarkus version or git rev

2.5.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: C:\opt\apache-maven-3.8.1\bin.. Java version: 11.0.11, vendor: AdoptOpenJDK

@onrclk onrclk added the kind/bug Something isn't working label Apr 20, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 20, 2022

/cc @Karm, @galderz, @zakkak

@Karm
Copy link
Member

Karm commented Apr 20, 2022

Hello @onrclk,

The workarounds you are following are dated.
Headless AWT image processing (like reading and writing images, basic fonts, geometry etc.) is supported via Quarkus AWT extension. If you require such functionality in your Quarkus project, you need to depend on the Quarkus AWT extension.

To see a real working example, take a look at the quickstart:

https://github.com/quarkusio/quarkus-quickstarts/tree/main/awt-graphics-rest-quickstart

With that said, if your project depends on some other third party library that on its own is trying to do something with graphics, there might be some additional work to make that third party library Native ready.

Start with the Quarkus AWT extension and see where it gets you.

Cheers
K

@Karm Karm closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants