quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.85k stars 2.7k forks source link

AWT Graphics does not seem to work in native image #19789

Closed ma-hab closed 3 years ago

ma-hab commented 3 years ago

Describe the bug

So basically I'm trying to resize png picture in quarkus app and I'm aware that there were several problems with AWT library. I tried following this comment but so far I cannot make this thing to work. The main culprit in stack trace seems to be this

Caused by: java.lang.UnsupportedOperationException: Not implemented yet for GraalVM native images
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:15)
        at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
        at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
        at com.test.ImageResource.resizeImage(ImageResource.java:63)
        at com.test.ImageResource.save(ImageResource.java:25)

I did create config files using agent like mentioned in that thread (you can check them here) but I'm wondering if perhaps there's something wrong with them.

Config files were crated the following way:

$GRAALVM_HOME/bin/java -agentlib:native-image-agent=config-output-dir=native-image-config -Djava.awt.headless=true -jar target/quarkus-app/quarkus-run.jar

How to Reproduce?

clone this https://github.com/habimt/rest-graphics and run ./mvnw verify -Pnative

Output of java -version

OpenJDK Runtime Environment (build 11.0.12+7)

GraalVM version (if different from Java)

GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08), also tried on 21.2.0.0-Final Mandrel Distribution (Java Version 11.0.12+7)

Quarkus version or git rev

2.1.4.Final

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

Apache Maven 3.8.1

quarkus-bot[bot] commented 3 years ago

/cc @galderz, @zakkak

gastaldi commented 3 years ago

FYI removing core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java gives

/tmp/rest-graphics (master ✘)✖✹ ᐅ ./mvnw verify -Pnative

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.test:rest-rest-graphics >---------------------
[INFO] Building rest-rest-graphics 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- quarkus-maven-plugin:999-SNAPSHOT:generate-code (default) @ rest-rest-graphics ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rest-rest-graphics ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ rest-rest-graphics ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- quarkus-maven-plugin:999-SNAPSHOT:generate-code-tests (default) @ rest-rest-graphics ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rest-rest-graphics ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/rest-graphics/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ rest-rest-graphics ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ rest-rest-graphics ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.test.ImageResourceTest
2021-08-30 21:02:18,929 INFO  [io.quarkus] (main) Quarkus 999-SNAPSHOT on JVM started in 1.816s. Listening on: http://localhost:8081
2021-08-30 21:02:18,953 INFO  [io.quarkus] (main) Profile test activated. 
2021-08-30 21:02:18,953 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb, smallrye-context-propagation]
HEADLESS: false
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.971 s - in com.test.ImageResourceTest
2021-08-30 21:02:20,750 INFO  [io.quarkus] (main) Quarkus stopped in 0.027s
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ rest-rest-graphics ---
[INFO] 
[INFO] --- quarkus-maven-plugin:999-SNAPSHOT:build (default) @ rest-rest-graphics ---
[INFO] [org.jboss.threads] JBoss Threads version 3.4.2.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /tmp/rest-graphics/target/rest-rest-graphics-1.0.0-SNAPSHOT-native-image-source-jar/rest-rest-graphics-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /tmp/rest-graphics/target/rest-rest-graphics-1.0.0-SNAPSHOT-native-image-source-jar/rest-rest-graphics-1.0.0-SNAPSHOT-runner.jar
[WARNING] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Cannot find the `native-image` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image` Attempting to fall back to container build.
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-native-image:21.2-java11
21.2-java11: Pulling from quarkus/ubi-quarkus-native-image
Digest: sha256:2b32e2494199c6096e68c66ffd7dc8b4924735e1e237c8d821deb5d2209b1da9
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:21.2-java11
quay.io/quarkus/ubi-quarkus-native-image:21.2-java11
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /tmp/rest-graphics/target/rest-rest-graphics-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --name build-native-qoATw quay.io/quarkus/ubi-quarkus-native-image:21.2-java11 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -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:+AllowIncompleteClasspath -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar rest-rest-graphics-1.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http -H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace -H:-ParseOnce rest-rest-graphics-1.0.0-SNAPSHOT-runner
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]    classlist:   2,330.52 ms,  0.93 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]        (cap):     592.49 ms,  0.93 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]        setup:   2,343.82 ms,  0.93 GB
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.
00:02:38,117 INFO  [org.jbo.threads] JBoss Threads version 3.4.2.Final
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]     (clinit):     673.78 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]   (typeflow):  13,093.97 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]    (objects):  17,016.11 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]   (features):   1,148.70 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]     analysis:  33,178.89 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]     universe:   1,704.03 ms,  4.70 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]      (parse):   6,055.67 ms,  5.65 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]     (inline):   3,570.32 ms,  5.33 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]    (compile):  29,021.59 ms,  6.24 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]      compile:  40,787.87 ms,  6.24 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]        image:   5,508.68 ms,  6.24 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]        write:     707.02 ms,  6.24 GB
[rest-rest-graphics-1.0.0-SNAPSHOT-runner:25]      [total]:  86,947.59 ms,  6.24 GB
# Printing build artifacts to: /project/rest-rest-graphics-1.0.0-SNAPSHOT-runner.build_artifacts.txt
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /tmp/rest-graphics/target/rest-rest-graphics-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --entrypoint /bin/bash quay.io/quarkus/ubi-quarkus-native-image:21.2-java11 -c objcopy --strip-debug rest-rest-graphics-1.0.0-SNAPSHOT-runner
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 93622ms
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M5:integration-test (default) @ rest-rest-graphics ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.test.NativeImageResourceIT
Executing [/tmp/rest-graphics/target/rest-rest-graphics-1.0.0-SNAPSHOT-runner, -Dquarkus.http.port=8081, -Dquarkus.http.ssl-port=8444, -Dtest.url=http://localhost:8081, -Dquarkus.log.file.path=/tmp/rest-graphics/target/quarkus.log, -Dquarkus.log.file.enable=true]
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-08-30 21:03:56,836 INFO  [io.quarkus] (main) rest-rest-graphics 1.0.0-SNAPSHOT native (powered by Quarkus 999-SNAPSHOT) started in 0.012s. Listening on: http://0.0.0.0:8081
2021-08-30 21:03:56,836 INFO  [io.quarkus] (main) Profile prod activated. 
2021-08-30 21:03:56,836 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb, smallrye-context-propagation]
[ERROR] WARNING: An illegal reflective access operation has occurred
[ERROR] WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v9.Java9 (file:/home/ggastald/.m2/repository/org/codehaus/groovy/groovy/3.0.8/groovy-3.0.8.jar) to constructor java.lang.AssertionError(java.lang.String)
[ERROR] WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v9.Java9
[ERROR] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[ERROR] WARNING: All illegal access operations will be denied in a future release
HEADLESS: true
2021-08-30 21:03:58,328 INFO  [io.ver.ext.web.RoutingContext] (executor-thread-0) RoutingContext failure (500): org.jboss.resteasy.spi.UnhandledException: java.lang.InternalError: Attempting to set SurfaceData ops twice
    at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
    at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
    at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.InternalError: Attempting to set SurfaceData ops twice
    at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_InternalError_2_0002e_0003cinit_0003e_00028Ljava_lang_String_2_00029V(JNIJavaCallWrappers.java:0)
    at com.oracle.svm.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer.invoke(JNIFunctions.java)
    at com.oracle.svm.jni.functions.JNIFunctions.ThrowNew(JNIFunctions.java:818)
    at sun.awt.image.BufImgSurfaceData.initRaster(BufImgSurfaceData.java)
    at sun.awt.image.BufImgSurfaceData.createDataBC(BufImgSurfaceData.java:318)
    at sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:101)
    at sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:74)
    at sun.awt.image.BufImgSurfaceManager.<init>(BufImgSurfaceManager.java:55)
    at sun.awt.image.SurfaceManager.getManager(SurfaceManager.java:79)
    at sun.java2d.SurfaceData.getPrimarySurfaceData(SurfaceData.java:274)
    at sun.java2d.SunGraphicsEnvironment.createGraphics(SunGraphicsEnvironment.java:184)
    at sun.java2d.HeadlessGraphicsEnvironment.createGraphics(HeadlessGraphicsEnvironment.java:70)
    at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1182)
    at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
    at com.test.ImageResource.resizeImage(ImageResource.java:63)
    at com.test.ImageResource.save(ImageResource.java:25)
    at java.lang.reflect.Method.invoke(Method.java:566)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
    at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
    at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
    ... 17 more

2021-08-30 21:03:58,328 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /save failed, error id: 162419d8-1d32-4d3c-92c6-819d92082699-1: org.jboss.resteasy.spi.UnhandledException: java.lang.InternalError: Attempting to set SurfaceData ops twice
    at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
    at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
    at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.InternalError: Attempting to set SurfaceData ops twice
    at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_InternalError_2_0002e_0003cinit_0003e_00028Ljava_lang_String_2_00029V(JNIJavaCallWrappers.java:0)
    at com.oracle.svm.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer.invoke(JNIFunctions.java)
    at com.oracle.svm.jni.functions.JNIFunctions.ThrowNew(JNIFunctions.java:818)
    at sun.awt.image.BufImgSurfaceData.initRaster(BufImgSurfaceData.java)
    at sun.awt.image.BufImgSurfaceData.createDataBC(BufImgSurfaceData.java:318)
    at sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:101)
    at sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:74)
    at sun.awt.image.BufImgSurfaceManager.<init>(BufImgSurfaceManager.java:55)
    at sun.awt.image.SurfaceManager.getManager(SurfaceManager.java:79)
    at sun.java2d.SurfaceData.getPrimarySurfaceData(SurfaceData.java:274)
    at sun.java2d.SunGraphicsEnvironment.createGraphics(SunGraphicsEnvironment.java:184)
    at sun.java2d.HeadlessGraphicsEnvironment.createGraphics(HeadlessGraphicsEnvironment.java:70)
    at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1182)
    at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1170)
    at com.test.ImageResource.resizeImage(ImageResource.java:63)
    at com.test.ImageResource.save(ImageResource.java:25)
    at java.lang.reflect.Method.invoke(Method.java:566)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
    at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
    at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
    ... 17 more

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.381 s <<< FAILURE! - in com.test.NativeImageResourceIT
[ERROR] com.test.NativeImageResourceIT.testSave  Time elapsed: 1.446 s  <<< FAILURE!
java.lang.AssertionError: 
1 expectation failed.
Expected status code <201> but was <500>.

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   NativeImageResourceIT>ImageResourceTest.testSave:34 1 expectation failed.
Expected status code <201> but was <500>.

[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M5:verify (default) @ rest-rest-graphics ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:45 min
[INFO] Finished at: 2021-08-30T21:03:58-03:00
[INFO] ------------------------------------------------------------------------
Karm commented 3 years ago

It's a longer journey than it seems, e.g. https://github.com/oracle/graal/pull/3417 I was fiddling with Quarkus' substitutions to get AWT to work, but ultimately, as Christian mentions, we cannot expect those AWT libs to work with being initialized at build time. There is too much state.

What you are doing is perfectly legit as long as it is all runtime initialized all the way, e.g.:

Without Quarkus

git clone https://github.com/Karm/mandrel-integration-tests
cd mandrel-integration-tests/apps/imageio/
mvn package
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/imageio.jar
jar uf target/imageio.jar -C src/main/resources/ META-INF
native-image -H:IncludeResources=Grace_M._Hopper.jp2,MyFreeMono.ttf,MyFreeSerif.ttf --no-fallback -jar target/imageio.jar target/imageio
./target/imageio

...and as you can see, mytest_Resized_Grace_M._Hopper.png is a resized version of src/main/resources/Grace_M._Hopper.jp2.

How to do it with Quarkus?

Removing the "safety", i.e.

deleted:    core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java

Enables us to initialize the graphics context. The "Not implemented yet for GraalVM native images" is there for a reason though as it is really not operational.

Apparently, we are sill touching the state twice in SurfaceData.c.

I came up with this update to your project, pushing graphics to be runtime initialized:

diff --git a/pom.xml b/pom.xml
index 6345003..db97856 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,8 +13,8 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
-    <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
-    <quarkus.platform.version>2.1.4.Final</quarkus.platform.version>
+    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
+    <quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
     <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
   </properties>
   <dependencyManagement>
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e69de29..b71b80c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+quarkus.native.additional-build-args=--trace-class-initialization=\
+java.awt.image.BufferedImage\\,\
+sun.java2d.HeadlessGraphicsEnvironment\\,\
+sun.java2d.SunGraphicsEnvironment\\,\
+sun.java2d.SurfaceData\\,\
+sun.awt.image.SurfaceManager\\,\
+sun.awt.image.BufImgSurfaceManager\\,\
+sun.awt.image.BufImgSurfaceData,\
+\
+--initialize-at-run-time=\
+java.awt.image.BufferedImage\\,\
+java.awt.Image\\,\
+sun.java2d.HeadlessGraphicsEnvironment\\,\
+java.awt.GraphicsEnvironment$LocalGE\\,\
+sun.java2d.SunGraphicsEnvironment\\,\
+sun.java2d.SurfaceData\\,\
+sun.awt.X11GraphicsEnvironment\\,\
+sun.awt.X11.XToolkit\\,\
+java.awt.Image\\,\
+sun.awt.image.SurfaceManager\\,\
+sun.awt.image.BufImgSurfaceManager\\,\
+sun.awt.image.BufImgSurfaceData
+

It "workarounds" the reinitialization problem at hand only to Segfault to whole JVM:

With GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08): (full log,

VM Thread State for current thread 00007f368c000b80:

  0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes) 
    00007f368c000b80: 00007f36995d4010

  8 (8 bytes): com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.stackBoundaryTL = (Word) 1  0000000000000001
  16 (4 bytes): com.oracle.svm.core.thread.Safepoint.safepointRequested = (int) 2147422075  7fff0f7b
  20 (4 bytes): com.oracle.svm.core.thread.VMThreads$StatusSupport.statusTL = (int) 1  00000001
  24 (32 bytes): com.oracle.svm.core.genscavenge.ThreadLocalAllocation.regularTLAB = (bytes) 
    00007f368c000b98: 00007f3692000000 00007f3692100000
    00007f368c000ba8: 00007f369209f730 00007f369bd84000

and also with native-image 21.3.0-devd63e6aab07 Mandrel Distribution (Java Version 11.0.13-ea+3)


[ [ SubstrateSegfaultHandler caught a segfault in thread 0x00007fe530000b80 ] ]
siginfo: si_signo: 11, si_code: 1, si_addr: 1048576

General purpose register values:
  RAX 0x00007fe53f900000 is the heap base
  RBX 0x00007fe530001550 [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 31.932 s <<< FAILURE! - in com.test.NativeImageResourceIT
[ERROR] com.test.NativeImageResourceIT.testSave  Time elapsed: 31.103 s  <<< ERROR!
java.net.SocketTimeoutException: Read timed out

Perhaps @jerboaa or @zakkak might have something to add....

jerboaa commented 3 years ago

TLDR; Quarkus uses unqualified build time initialization, think --initialize-at-build-time=, which breaks when using AWT, which your example app uses. It's unlikely that graal would support AWT with build-time-initialization. As @Karm pointed out, that's explained in https://github.com/oracle/graal/pull/3417, particularly this comment. So in order to make this example, or any ImageIO apps, work with Quarkus, Quarkus would have to support a way to opt out of build-time-initialization for everything.

A couple of comments:

What you are doing is perfectly legit as long as it is all runtime initialized all the way, e.g.:

In a way it's not "perfectly legit" when Quarkus is being used. As there is the fundamental clash between runtime-init (Graal) vs. build-time-init-for-everything (Quarkus).

Without Quarkus

git clone https://github.com/Karm/mandrel-integration-tests
cd mandrel-integration-tests/apps/imageio/
mvn package
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/imageio.jar
jar uf target/imageio.jar -C src/main/resources/ META-INF
native-image -H:IncludeResources=Grace_M._Hopper.jp2,MyFreeMono.ttf,MyFreeSerif.ttf --no-fallback -jar target/imageio.jar target/imageio
./target/imageio

Yes, upstream Graal VM supports AWT, but only with runtime initialization and aiding the points-to analysis with relevant config (native-image-agent step above).

...and as you can see, mytest_Resized_Grace_M._Hopper.png is a resized version of src/main/resources/Grace_M._Hopper.jp2.

How to do it with Quarkus?

Removing the "safety", i.e.

deleted:    core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java

That's not sufficient. At the very least, https://github.com/quarkusio/quarkus/pull/17986, would need to be reverted, --initialize-at-build-time= removed from NativeImageBuildStep.java and possibly more as I get other errors when quarkus doesn't build-time-inits everything. I didn't go further down this rabbit hole...

Enables us to initialize the graphics context. The "Not implemented yet for GraalVM native images" is there for a reason though as it is really not operational.

Yes, --^ that.

It "workarounds" the reinitialization problem at hand only to Segfault to whole JVM:

This is likely an observed Segfault, as mentioned in Aleksandar's comment. He called it "segfault in disguise" ;-)

I believe the only viable workaround for using such an app with Quarkus is to run it with JVM mode. At least for now.

jerboaa commented 3 years ago

I did create config files using agent like mentioned in that thread (you can check them here) but I'm wondering if perhaps there's something wrong with them.

@habimt How did you produce those? If I try to recreate it using this, I get a diff (see below):

$ java -agentlib:native-image-agent=config-output-dir=$(pwd)/src/main/resources/META-INF/native-image -jar target/quarkus-app/quarkus-run.jar &
$ curl -v -X POST -H "Content-Type: application/json" -d "@../image_json_content.json" http://127.0.0.1:8080/save
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /save HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.76.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 5881
> 
HEADLESS: false
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 Created
< Content-Length: 0
< 
* Connection #0 to host 127.0.0.1 left intact
$ cat ../image_json_content.json
{
  "content": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZMAAAC5CAYAAADtXNKFAAAQsUlEQVR4Xu3dW6hUZRsH8PfrvsygwAjKLgwis7Ik6KKSIAjTCkUi7CAkQdERIm86XQRCJ6sL6yKz0DA7IwQFlYEmSJkR4YVIRdCRDhfdSNn3PfMxw97j7Nkz+1lz2vN7YbMz13rWrN96nf+8611rzX+OHj36b9EIECBAgEBC4D/CJKFnVQIECBCoCQgTHYEAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2oAAECBAgIE32AAAECBNICwiRNqAABAgQICBN9gAABAgTSAsIkTagAAQIECAgTfYAAAQIE0gLCJE2owKAE/vjjj1L/+fPPP495Gf/++28544wzaj8aAQK9FRAmvfVVPSGwa9eu8s0339QC49tvv639d/0n/l837cQTTyznnXdeqf++9NJLy+mnny5oukG0LIE2AsJE9xiYQATD7t27y+HDh0uMIr744osZh8VMdyLC5bLLLqsFTQRM/GgECHQvIEy6N7PGDAU+/vjj8sknn5T4HT/D2iJYImAiWBYtWmT0MuAD9csvv5STTz65HDp0qBw5cqT8/PPPteOjDZeAMBmu4zHrXk2Exssvv1zefvvt2umqKtqcOXNqb/Axqqi3+p9jG/H/43eMfKLFfx84cGDGm47a8eYVwbJixQrhMmPJ7lZ89tlny5tvvlnidGerdtNNN5WHHnrI8eiOtWdLC5Oe0Y534QiPRx99tHbqqttWn8uoT57X/xwh0Rwi3dSOUInXEz8xBxO/p3qjalf3tNNOKxdeeGFt5CJcujkCnS27c+fO8sgjj5TPPvusoxUiUOJHG6yAMBms/6zbeoxE7r333o5CJEIiTiktXLiwLFmypMSbdPy53y1ec4xiIlgiYLodxdRPi914440Def399url9iJIli9f3vUmtm/fXlatWtX1elaoTkCYVGc51pXiU/8zzzxTnn766bans+KTfPzEaaNhvWS3PoKJcIkRVjfhEvsUn5JjHyeehhvrztHFzh933HHHLH311VeX+fPn10aTYVoP/uYFjVC6gO7BosKkB6jjVjL+ca9du3bKSfWY47j77rvLXXfdNZJvsPVwef7558v+/fvLTz/9VFrd1zLxuMeb3s0331wefPDBkdznfvfhGBFGH2o+LTrViCMm46+//vpJp8LmzZtX+zBjhNLvo/f/7QmTwbjPmq3GP96YG5lqcj0CJD4xzrZP6XFq7J133qmNXOIT81Qt9jv2PyaLZ5tBlZ34zDPPbFwwUa/74YcfTnvV1urVq8uOHTsaLyUukojA1/ovIEz6bz4rtjjdaCT+UW/evHks5hDCYsuWLbVPxVONWGJe5cUXXxwLj247+MqVK2tXbU1se/bsKRdffPG0pfbu3Vuuu+668uOPPzaWfffdd8uyZcumXdcC1QoIk2o9x6LadKOR+CQ+qqe0sgfwpZdeKhs3bpxynuXJJ5+snfLT/i/wwgsvlNtuu20SR1wSfPvtt3dMFH0t1plJGHW8EQtOKyBMpiWyQF1gust94+qsGI24oayUCJV77rmn5UglfOKTuNNe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8ODBli92WO8nGbzs+LwCYTI+x9qeEphWYPny5WXnzp3TLjdxAUHSFdesXViYzNpDa8cIzExg7969tdNeu3btalsgrv6K7weJkYtGQJjoAwQItBSIx41s27at7Nu3b9Lfx0hk2bJlZfHixeQINASEic5AgEBbge+//778/fff5ciRI2XBggW0CLQUECY6BgECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQECb6AAECBAikBYRJmlABAgQIEBAm+gABAgQIpAWESZpQAQIECBAQJvoAAQIECKQFhEmaUAECBAgQ+C9CtmAUEj4ccwAAAABJRU5ErkJggg==",
  "path": "image_test/img2.png",
  "properties": { "height": 100 }
}

produced this diff to your repo:

$ git diff
diff --git a/src/main/resources/META-INF/native-image/jni-config.json b/src/main/resources/META-INF/native-image/jni-config.json
index 81cd1d3..e311acd 100644
--- a/src/main/resources/META-INF/native-image/jni-config.json
+++ b/src/main/resources/META-INF/native-image/jni-config.json
@@ -8,8 +8,30 @@
 },
 {
   "name":"java.awt.Color",
+  "fields":[{"name":"value"}],
   "methods":[{"name":"getRGB","parameterTypes":[] }]
 },
+{
+  "name":"java.awt.Font",
+  "fields":[
+    {"name":"pData"}, 
+    {"name":"size"}, 
+    {"name":"style"}
+  ],
+  "methods":[
+    {"name":"getFamily_NoClientCode","parameterTypes":[] }, 
+    {"name":"getFontPeer","parameterTypes":[] }
+  ]
+},
+{
+  "name":"java.awt.Insets",
+  "fields":[
+    {"name":"bottom"}, 
+    {"name":"left"}, 
+    {"name":"right"}, 
+    {"name":"top"}
+  ]
+},
 {
   "name":"java.awt.geom.AffineTransform",
   "fields":[
@@ -106,22 +128,33 @@
   ]
 },
 {
-  "name":"java.lang.ClassLoader",
+  "name":"sun.awt.SunHints",
+  "fields":[{"name":"INTVAL_STROKE_PURE"}]
+},
+{
+  "name":"sun.awt.SunToolkit",
   "methods":[
-    {"name":"getPlatformClassLoader","parameterTypes":[] }, 
-    {"name":"loadClass","parameterTypes":["java.lang.String"] }
+    {"name":"awtLock","parameterTypes":[] }, 
+    {"name":"awtLockNotify","parameterTypes":[] }, 
+    {"name":"awtLockNotifyAll","parameterTypes":[] }, 
+    {"name":"awtLockWait","parameterTypes":["long"] }, 
+    {"name":"awtUnlock","parameterTypes":[] }
   ]
 },
 {
-  "name":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"
+  "name":"sun.awt.X11.XErrorHandlerUtil",
+  "methods":[{"name":"init","parameterTypes":["long"] }]
 },
 {
-  "name":"org.graalvm.nativebridge.jni.JNIExceptionWrapperEntryPoints",
-  "methods":[{"name":"getClassName","parameterTypes":["java.lang.Class"] }]
+  "name":"sun.awt.X11.XToolkit",
+  "fields":[
+    {"name":"modLockIsShiftLock"}, 
+    {"name":"numLockMask"}
+  ]
 },
 {
-  "name":"sun.awt.SunHints",
-  "fields":[{"name":"INTVAL_STROKE_PURE"}]
+  "name":"sun.awt.X11GraphicsDevice",
+  "fields":[{"name":"screen"}]
 },
 {
   "name":"sun.awt.image.BufImgSurfaceData$ICMColorData",
@@ -339,6 +372,13 @@
     {"name":"region"}
   ]
 },
+{
+  "name":"sun.java2d.xr.XRSurfaceData",
+  "fields":[
+    {"name":"picture"}, 
+    {"name":"xid"}
+  ]
+},
 {
   "name":"sun.management.VMManagementImpl",
   "fields":[
diff --git a/src/main/resources/META-INF/native-image/reflect-config.json b/src/main/resources/META-INF/native-image/reflect-config.json
index cd92349..6ae85ad 100644
--- a/src/main/resources/META-INF/native-image/reflect-config.json
+++ b/src/main/resources/META-INF/native-image/reflect-config.json
@@ -188,10 +188,18 @@
   "name":"io.quarkus.runner.GeneratedMain",
   "methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
 },
+{
+  "name":"io.smallrye.config.ConfigMessages_$bundle",
+  "fields":[{"name":"INSTANCE"}]
+},
 {
   "name":"io.smallrye.config.PropertiesLocationConfigSourceFactory",
   "methods":[{"name":"<init>","parameterTypes":[] }]
 },
+{
+  "name":"io.smallrye.context.api.ManagedExecutorConfig",
+  "allDeclaredMethods":true
+},
 {
   "name":"io.vertx.core.http.impl.Http1xOrH2CHandler",
   "methods":[{"name":"channelRead","parameterTypes":["io.netty.channel.ChannelHandlerContext","java.lang.Object"] }]
galderz commented 3 years ago

A draft PR to fix this: #20148

ma-hab commented 3 years ago

@jerboaa

$GRAALVM_HOME/bin/java -agentlib:native-image-agent=config-output-dir=native-image-config -Djava.awt.headless=true -jar target/quarkus-app/quarkus-run.jar

I ran the jar using headless mode -Djava.awt.headless=true since that is used in native image. I edited the original comment to include that info