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 failure: Can't load standard profile: GRAY.pf #12972

Closed
JiriOndrusek opened this issue Oct 27, 2020 · 13 comments · Fixed by #20850
Closed

Quarkus-native failure: Can't load standard profile: GRAY.pf #12972

JiriOndrusek opened this issue Oct 27, 2020 · 13 comments · Fixed by #20850
Labels
kind/bug Something isn't working
Milestone

Comments

@JiriOndrusek
Copy link
Contributor

Describe the bug
During implementation of camel-quarkus extension of camel-barcode, I've faced an issue linked to awt profile: Can't load standard profile: GRAY.pf

Expected behavior
No error is happening and profile is loaded.

Actual behavior
See reproducer. Stacktrace of the exception is:

2020-10-27 10:25:19,819 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.IllegalArgumentException: Can't load standard profile: GRAY.pf
at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:942)
at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:936)
at java.security.AccessController.doPrivileged(AccessController.java:83)
at java.awt.color.ICC_Profile.getStandardProfile(ICC_Profile.java:935)
at java.awt.color.ICC_Profile.getDeferredInstance(ICC_Profile.java:1067)
at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:902)
at java.awt.color.ColorSpace.getInstance(ColorSpace.java:333)
at javax.imageio.ImageTypeSpecifier$Grayscale.(ImageTypeSpecifier.java:604)
at javax.imageio.ImageTypeSpecifier.createGrayscale(ImageTypeSpecifier.java:685)
at javax.imageio.ImageTypeSpecifier.createSpecifier(ImageTypeSpecifier.java:1211)
at javax.imageio.ImageTypeSpecifier.getSpecifier(ImageTypeSpecifier.java:1118)
at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:931)
at javax.imageio.ImageIO.getWriter(ImageIO.java:1608)
at javax.imageio.ImageIO.write(ImageIO.java:1594)
at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:159)
at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:144)
at org.acme.commandmode.HelloCommando.run(HelloCommando.java:36)
at org.acme.commandmode.HelloCommando_ClientProxy.run(HelloCommando_ClientProxy.zig:157)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:115)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:62)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:30)

To Reproduce

Here is a simple roproducer: https://github.com/JiriOndrusek/cannot-find-gray-pf-reproducer
Dev mode works correctly, but native mode fails with above exception.

Additional context
I was looking into some graalvm jdks for java 8 and there was a file /jre/lib/cmm/GRAY.pf which is not present in graalvm jdk for java 11. But the same problem is happening if graalvm-ce-java8-20.2.0 is used, so there is probably no influence.
But just the fact that file existin graalvm-ce-java8-20.2.0, shows that it should work.

@jeesmon
Copy link

jeesmon commented Jan 26, 2021

@JiriOndrusek Are you aware of any fix to this issue yet? We are running into same issue when trying to process a DICOM image in native mode. Thanks.

@JiriOndrusek
Copy link
Contributor Author

JiriOndrusek commented Jan 26, 2021

@jeesmon I'm not aware of any fix to that issue. But there are some issues linked to awt, which are probably being solved right now (e.g. graalvm/mandrel#180, oracle/graal#1163, #12393) and there is a change, that it will have positive impact to this issue.

@gsmet
Copy link
Member

gsmet commented Jan 26, 2021

I would try with either GraalVM 20.3.1 or GraalVM 21.

@jeesmon
Copy link

jeesmon commented Jan 26, 2021

@gsmet No luck :(

Caused by: java.lang.UnsupportedOperationException: Not implemented yet for GraalVM native images
	at sun.java2d.cmm.lcms.LCMS.loadProfileNative(LCMS.java:13)
	at sun.java2d.cmm.lcms.LCMS.loadProfile(LCMS.java:42)
	at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:790)
	at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:1026)
	at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:991)
	at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:940)
	at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:936)
	at java.security.AccessController.doPrivileged(AccessController.java:84)
	at java.awt.color.ICC_Profile.getStandardProfile(ICC_Profile.java:935)
	at java.awt.color.ICC_Profile.getDeferredInstance(ICC_Profile.java:1067)
	at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:902)
	at java.awt.color.ColorSpace.getInstance(ColorSpace.java:333)

quarkus: 1.11.0.Final
Graalvm: 21.0.0-java11

@zakkak
Copy link
Contributor

zakkak commented Jan 27, 2021

@jeesmon could you please share a reproducer?

@jeesmon
Copy link

jeesmon commented Jan 27, 2021

@zakkak I will share a reproducer very soon. Thanks.

@gsmet
Copy link
Member

gsmet commented Jan 27, 2021

So it's indeed a bit better because the exception you have here comes from Quarkus, namely Target_sun_java2d_cmm_lcms_LCMS.

@zakkak I wonder if we could remove all these substitutions and see how it goes now that they did some work in this area.

@gsmet
Copy link
Member

gsmet commented Jan 27, 2021

BTW, a bit unrelated but we might also want to revisit Target_java_io_ObjectStreamClass if serialization is now implemented.

@jeesmon
Copy link

jeesmon commented Jan 27, 2021

@zakkak @gsmet Reproducer is available here: https://github.com/jeesmon/issue-12972

@jeesmon
Copy link

jeesmon commented Feb 9, 2021

@zakkak @gsmet Any update on this? Thanks.

@zakkak
Copy link
Contributor

zakkak commented Feb 9, 2021

@jeesmon sorry for not posting any updates.
I was able to reproduce with @JiriOndrusek 's example.

Removing the LCMS substitutions (core/runtime/src/main/java/io/quarkus/runtime/graal/LCMSSubstitutions.java) and using GraalVM CE 21.0.0 I am getting:

Exception in thread "main" java.lang.NoClassDefFoundError: Lsun/java2d/Disposer;
        at com.oracle.svm.jni.functions.JNIFunctions.FindClass(JNIFunctions.java:325)
        at sun.java2d.cmm.lcms.LCMS.loadProfileNative(LCMS.java)
        at sun.java2d.cmm.lcms.LCMS.loadProfile(LCMS.java:42)
        at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:790)
        at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:1026)
        at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:991)
        at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:940)
        at java.awt.color.ICC_Profile$2.run(ICC_Profile.java:936)
        at java.security.AccessController.doPrivileged(AccessController.java:84)
        at java.awt.color.ICC_Profile.getStandardProfile(ICC_Profile.java:935)
        at java.awt.color.ICC_Profile.getDeferredInstance(ICC_Profile.java:1067)
        at java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:902)
        at java.awt.color.ColorSpace.getInstance(ColorSpace.java:333)
        at javax.imageio.ImageTypeSpecifier$Grayscale.<init>(ImageTypeSpecifier.java:604)
        at javax.imageio.ImageTypeSpecifier.createGrayscale(ImageTypeSpecifier.java:685)
        at javax.imageio.ImageTypeSpecifier.createSpecifier(ImageTypeSpecifier.java:1211)
        at javax.imageio.ImageTypeSpecifier.getSpecifier(ImageTypeSpecifier.java:1118)
        at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:931)
        at javax.imageio.ImageIO.getWriter(ImageIO.java:1608)
        at javax.imageio.ImageIO.write(ImageIO.java:1594)
        at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:159)
        at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:144)
        at org.acme.commandmode.HelloCommando.run(HelloCommando.java:36)
        at org.acme.commandmode.HelloCommando_ClientProxy.run(HelloCommando_ClientProxy.zig:129)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:122)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
        at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:30)

Running:

cd ./target/barcode-with-quarkus-1.0.0-SNAPSHOT-native-image-source-jar/
mkdir META-INF
$GRAALVM_HOME/bin/java \
  -agentlib:native-image-agent=config-output-dir=./META-INF/native-image \
  -jar barcode-with-quarkus-1.0.0-SNAPSHOT-runner.jar
$GRAALVM_HOME/bin/native-image \
  -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager \
  -J-Duser.language=en \
  -J-Duser.country=IE \
  -J-Dfile.encoding=UTF-8 \
  --initialize-at-build-time= \
  -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime \
  -H:+JNI \
  -H:+AllowFoldMethods \
  -jar barcode-with-quarkus-1.0.0-SNAPSHOT-runner.jar \
  -H:FallbackThreshold=0 \
  -H:+ReportExceptionStackTraces \
  -H:-AddAllCharsets \
  -H:EnableURLProtocols=http \
  -H:NativeLinkerOption=-no-pie \
  --no-server \
  -H:-UseServiceLoaderFeature \
  -H:+StackTrace \
  barcode-with-quarkus-1.0.0-SNAPSHOT-runner

I was able to get the application to start but it crashes (segmentation fault), so more work is needed to support this.

Furthermore to make the above procedure user friendly we need to implement #13567.

@jeesmon
Copy link

jeesmon commented Feb 9, 2021

Thanks for the quick update @zakkak

@Karm
Copy link
Member

Karm commented Oct 18, 2021

Hello @JiriOndrusek, @jeesmon
This issue can be closed with resolved by #20850.

I tested your reproducer with more or less (today's) quarkus main as is (rearranged pom), using early access mandrel-java11-linux-amd64-21.3.0.0-Final.tar.gz (JDK 11.0.13+7 ea):

It fails as expected:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 21.3.0.0-Final Mandrel Distribution (Java Version 11.0.13-ea+7)
...
2021-10-19 01:38:29,350 INFO  [io.quarkus] (main) barcode-with-quarkus 1.0.0-SNAPSHOT native (powered by Quarkus 999-SNAPSHOT) started in 0.006s. 
2021-10-19 01:38:29,350 INFO  [io.quarkus] (main) Profile prod activated. 
2021-10-19 01:38:29,351 INFO  [io.quarkus] (main) Installed features: [cdi]
Exception in thread "main" java.lang.NoSuchFieldError: java.awt.image.ColorModel.pData
        at com.oracle.svm.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1126)
        at com.oracle.svm.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:428)
        at java.awt.image.ColorModel.initIDs(ColorModel.java)
        at java.awt.image.ColorModel.<clinit>(ColorModel.java:220)
        at java.awt.image.BufferedImage.<clinit>(BufferedImage.java:286)
        at com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(MatrixToImageWriter.java:63)
        at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:158)
        at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:144)
        at org.acme.commandmode.HelloCommando.run(HelloCommando.java:36)
        at org.acme.commandmode.HelloCommando_ClientProxy.run(HelloCommando_ClientProxy.zig:129)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:127)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:30)

When I add the new AWT extension, it is all peachy:

+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-awt</artifactId>
+    </dependency>
$ ./target/barcode-with-quarkus-1.0.0-SNAPSHOT-runner 
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-10-19 01:40:48,823 INFO  [io.quarkus] (main) barcode-with-quarkus 1.0.0-SNAPSHOT native (powered by Quarkus 999-SNAPSHOT) started in 0.005s. 
2021-10-19 01:40:48,823 INFO  [io.quarkus] (main) Profile prod activated. 
2021-10-19 01:40:48,823 INFO  [io.quarkus] (main) Installed features: [awt, cdi]
done
2021-10-19 01:40:48,829 INFO  [io.quarkus] (main) barcode-with-quarkus stopped in 0.000s

@quarkus-bot quarkus-bot bot added this to the 2.6 - main milestone Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants