Does Aspose provide support for GraalVM native image when using Java libraries with version. 23.01

We are trying to build Graalvm native image for our spring boot application which internally uses aspose library which to used read and miniplate data in Excell sheet.

But i observed that aspose library is not getting compiled in native image hence its unable to create aspose webbook instance. so wanted to know if aspose support Graalvm native image? if yes could you please share some code snippet how it works

Getting this error

java.lang.NoSuchMethodError: java.awt.Toolkit.getDefaultToolkit()Ljava/awt/Toolkit;
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1267)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1252)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetStaticMethodID(JNIFunctions.java:420)
at java.desktop@17.0.7/java.awt.Toolkit.initIDs(Native Method)
at java.desktop@17.0.7/java.awt.Toolkit.initStatic(Toolkit.java:1425)
at java.desktop@17.0.7/java.awt.Toolkit.(Toolkit.java:1397)
at java.desktop@17.0.7/java.awt.Color.(Color.java:277)
at java.base@17.0.7/java.lang.Class.ensureInitialized(DynamicHub.java:579)
at com.aspose.cells.a.a.z3.(Unknown Source)
at com.aspose.cells.l3f.h(Unknown Source)
at com.aspose.cells.l3f.g(Unknown Source)
at com.aspose.cells.l3f.b(Unknown Source)
at com.aspose.cells.l3f.a(Unknown Source)
at com.aspose.cells.r65.a(Unknown Source)
at com.aspose.cells.r65.(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

@zeeshankarimkhan,

What is the error? Please see the thread for your reference.

java.lang.NoSuchMethodError: java.awt.Toolkit.getDefaultToolkit()Ljava/awt/Toolkit;
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1267)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1252)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetStaticMethodID(JNIFunctions.java:420)
at java.desktop@17.0.7/java.awt.Toolkit.initIDs(Native Method)
at java.desktop@17.0.7/java.awt.Toolkit.initStatic(Toolkit.java:1425)
at java.desktop@17.0.7/java.awt.Toolkit.(Toolkit.java:1397)
at java.desktop@17.0.7/java.awt.Color.(Color.java:277)
at java.base@17.0.7/java.lang.Class.ensureInitialized(DynamicHub.java:579)
at com.aspose.cells.a.a.z3.(Unknown Source)
at com.aspose.cells.l3f.h(Unknown Source)
at com.aspose.cells.l3f.g(Unknown Source)
at com.aspose.cells.l3f.b(Unknown Source)
at com.aspose.cells.l3f.a(Unknown Source)
at com.aspose.cells.r65.a(Unknown Source)
at com.aspose.cells.r65.(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.x8q.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

@zeeshankarimkhan,

Please see the suggested thread especially the reply there:

Thanks for Reply … I will try this and get back to you on this

I tried with simple code to create buffer image still getting this error

  java.awt.image.BufferedImage bi = new java.awt.image.BufferedImage (200, 200, java.awt.image.BufferedImage.TYPE_INT_RGB);
    Graphics2D graph = bi.createGraphics();
    graph.setColor(Color.RED);
    graph.fillRect(50,50,100,100);
    graph.dispose();
    File of =new File("D:\\Users\\test\\poc_projects\\test.png");
    ImageIO.write(bi,"png",of);

ERROR :
java.lang.NoSuchFieldError: java.awt.image.ColorModel.pData
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1279)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:432)
at java.desktop@17.0.7/java.awt.image.ColorModel.initIDs(Native Method)
at java.desktop@17.0.7/java.awt.image.ColorModel.(ColorModel.java:221)
at java.desktop@17.0.7/java.awt.image.BufferedImage.(BufferedImage.java:286)

@zeeshankarimkhan,

As we told in other thread, the issue is mainly caused by java.awt.* APIs such as java.awt.Font, java.awt.BufferedImage. It seems that graalvm does not support those APIs yet. Even for applications without involving Aspose APIs, when you remove the reference to Aspose.Cells in your project and test your sample code, you still get the error.
So, the error will still be reported when you run the generated native image.

Please note, for our component, those APIs are essential and many basic functions depend on them. So we are afraid you cannot use it with graalvm to build native image until graalvm supports java.awt.* better.

We are working on only Excell sheet. does aspose library still require java awt component for Excell sheet proccing?

@zeeshankarimkhan,

Yes, Aspose.Cells uses java.awt APIs to implement different tasks and relevant features. So, we are afraid you may not use it with graalvm to build native image until graalvm supports java.awt.*.

Thank you for confirmation.