Dear Spring Team,
We use the below-mentioned code in a simple spring application.
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) throws IOException {
SpringApplication.run(DemoApplication.class, args);
File openBadgeFile = new File("/home/dilip/Desktop/demo/src/main/resources/test.png");
PDDocument document = PDDocument.load(new File("/home/dilip/Desktop/demo/src/main/resources/test.pdf"));
PDFRenderer pdfRenderer = new PDFRenderer(document);
BufferedImage bImage = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB);
ImageIO.write(bImage, "PNG", openBadgeFile);
document.close();
}
}
While creating the native build at that time we face the below-mentioned error.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0)
2022-12-17T00:42:33.826+05:30 INFO 10967 --- [ main] com.example.demo.DemoApplication : Starting AOT-processed DemoApplication using Java 17.0.5 with PID 10967 (/home/dilip/Desktop/demo/build/native/nativeCompile/demo started by dilip in /home/dilip/Desktop/demo)
2022-12-17T00:42:33.826+05:30 INFO 10967 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default"
2022-12-17T00:42:33.832+05:30 INFO 10967 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 0.016 seconds (process running for 0.019)
Exception in thread "main" java.lang.NoSuchFieldError: java.awt.image.ColorModel.pData
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1271)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:425)
at java.desktop@17.0.5/java.awt.image.ColorModel.initIDs(ColorModel.java)
at java.desktop@17.0.5/java.awt.image.ColorModel.<clinit>(ColorModel.java:221)
at java.desktop@17.0.5/java.awt.image.Raster.<clinit>(Raster.java:172)
at org.apache.pdfbox.pdmodel.PDDocument.<clinit>(PDDocument.java:107)
at com.example.demo.DemoApplication.main(DemoApplication.java:20)
Is there any additional configuration that we need to do while creating the native build.
NOTE:: We are using apache-pdfbox dependency with its latest version.
Comment From: bclozel
Thanks for reaching out and trying our GraalVM Native support. Unfortunately, I think this one is out of our control. You should reach out to the "apache-pdfbox" and ask them to consider GraalVM Native image support. If the community is not interested in this right now, you can also work on contributing metadata on the community repository. Also see this announcement from the GraalVM team.
The Spring team has contributed metadata for many libraries already, but we are currently focusing on libraries that we provide support for.
Comment From: rishiraj88
Thanks for reaching out and trying our GraalVM Native support. Unfortunately, I think this one is out of our control. You should reach out to the "apache-pdfbox" and ask them to consider GraalVM Native image support. If the community is not interested in this right now, you can also work on contributing metadata on the community repository. Also see this announcement from the GraalVM team.
The Spring team has contributed metadata for many libraries already, but we are currently focusing on libraries that we provide support for.
Thank you very much, @bclozel , for your response.