-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
AWT Graphics does not seem to work in native image #19789
Comments
FYI removing /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] ------------------------------------------------------------------------ |
It's a longer journey than it seems, e.g. oracle/graal#3417 What you are doing is perfectly legit as long as it is all runtime initialized all the way, e.g.: Without Quarkusgit 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, How to do it with Quarkus?Removing the "safety", i.e.
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,
and also with native-image 21.3.0-devd63e6aab07 Mandrel Distribution (Java Version 11.0.13-ea+3)
|
TLDR; Quarkus uses unqualified build time initialization, think A couple of comments:
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).
Yes, upstream Graal VM supports AWT, but only with runtime initialization and aiding the points-to analysis with relevant config (
That's not sufficient. At the very least, #17986, would need to be reverted,
Yes, --^ that.
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. |
@habimt How did you produce those? If I try to recreate it using this, I get a diff (see below):
produced this diff to your repo:
|
A draft PR to fix this: #20148 |
I ran the jar using headless mode |
* Even though reflection and JNI registrations happen in the AWT extenssion, runtime initialization packages are defined in core. * This is done to avoid sun.java2d, and related classes, to be build time initialized, which causes issues with other modules. * Move ImageIO test from main to awt. * Make Apache Tika depend on AWT extension * Mark Tika packages that need runtime initialization for AWT. This definition can happen directly at the Tika extension level. Fix formatting
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
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:
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
orgradlew --version
)Apache Maven 3.8.1
The text was updated successfully, but these errors were encountered: