Aspose.Words is loading JAI- but POM doesn't list JAI as a dependency

We caught Aspose 16.10.0 trying to read a BMP using JAI, which fails because nobody declared a dependency on jai-codec:


java.lang.NoClassDefFoundError: com.sun.media.jai.codec.SeekableStream
at javax.media.jai.operator.BMPDescriptor.class$(BMPDescriptor.java:86)
at javax.media.jai.operator.BMPDescriptor.(BMPDescriptor.java:85)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at javax.media.jai.RegistryFileParser.getInstance(RegistryFileParser.java:216)
at javax.media.jai.RegistryFileParser.registerDescriptor(RegistryFileParser.java:352)
at javax.media.jai.RegistryFileParser.parseFile(RegistryFileParser.java:287)
at javax.media.jai.RegistryFileParser.loadOperationRegistry(RegistryFileParser.java:47)
at javax.media.jai.OperationRegistry.initializeRegistry(OperationRegistry.java:363)
at javax.media.jai.JAI.(JAI.java:560)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at asposewobfuscated.zzLC.zzs(Unknown Source)
at asposewobfuscated.zzLD.zzt(Unknown Source)
at asposewobfuscated.zzLD.zzS(Unknown Source)
at asposewobfuscated.zzLD.zzv(Unknown Source)
at asposewobfuscated.zzPG.zz2(Unknown Source)
at com.aspose.words.zzC6.zzce(Unknown Source)
at com.aspose.words.zzC6.zzh6(Unknown Source)
at com.aspose.words.zzC4.zzZ(Unknown Source)
at com.aspose.words.zz92.zzK(Unknown Source)
at com.aspose.words.zz92.zzZ(Unknown Source)
at com.aspose.words.zzB1.zzZ(Unknown Source)
at com.aspose.words.zzB1.zzZ(Unknown Source)
at com.aspose.words.zzZMH.zzX(Unknown Source)
at com.aspose.words.zzZMH.zzY(Unknown Source)
at com.aspose.words.zzYZ4.getSize(Unknown Source)
at com.aspose.words.zzYZ4.zzZml(Unknown Source)
at com.aspose.words.zzYZ3.getWidth(Unknown Source)
at com.aspose.words.zzYZ5.zzte(Unknown Source)
at com.aspose.words.zzZ01.getWidth(Unknown Source)
at com.aspose.words.zzZLT.zzZMw(Unknown Source)
at com.aspose.words.zzZLT.zzW(Unknown Source)
at com.aspose.words.zzZLZ.zzV(Unknown Source)
at com.aspose.words.zzZLY.zzZ(Unknown Source)
at com.aspose.words.zzW4.zzZ(Unknown Source)
at com.aspose.words.zzZ0F.zzZ(Unknown Source)
at com.aspose.words.zzXI.zzuz(Unknown Source)
at com.aspose.words.zzXI.zzY(Unknown Source)
at com.aspose.words.zzZ95.zzZz3(Unknown Source)
at com.aspose.words.zzZ95.zzT(Unknown Source)
at com.aspose.words.zzZ8K.zzx(Unknown Source)
at com.aspose.words.zzYYJ.zzRZ(Unknown Source)
at com.aspose.words.zz7Z.zzXD(Unknown Source)
at com.aspose.words.zz80.zz7v(Unknown Source)
at com.aspose.words.zzZN0.zzZ(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.zzXF(Unknown Source)
at com.aspose.words.Document.getPageCount(Unknown Source)
at com.aspose.words.zzZZN.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)

It seems a little odd to use JAI just to read a BMP file, when ImageIO would work fine. However, Aspose’s published POM does not declare this dependency on JAI, and I think that should be fixed.

Hi Nicholas,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document and BMP.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

I’m still waiting for test data myself. I tried to make some using Aspose itself, but it turns out Aspose is incapable of putting a BMP into a document. :confused:


I can clearly see the code in the Aspose class loading JAI, though. It’s using sneaky reflection to do it:

static BufferedImage zzs(zzAI var0) throws Exception {
Class var1 = Class.forName(“javax.media.jai.JAI”);
Class var2 = Class.forName(“com.sun.media.jai.codec.ByteArraySeekableStream”);
Class var3 = Class.forName(“javax.media.jai.PlanarImage”);
Method var4;
(var4 = var2.getMethod(“wrapInputStream”, new Class[]{InputStream.class, Boolean.TYPE})).setAccessible(true);
Object var5 = var4.invoke((Object)null, new Object[]{new zz5M(var0), Boolean.valueOf(true)});
Method var6;
(var6 = var1.getMethod(“create”, new Class[]{String.class, Object.class})).setAccessible(true);
Object var7 = var6.invoke((Object)null, new Object[]{“stream”, var5});
Method var8;
(var8 = var3.getMethod(“getAsBufferedImage”, new Class[0])).setAccessible(true);
return (BufferedImage)var8.invoke(var7, new Object[0]);
}

Hi Nicholas,

Thanks for your inquiry. Please refer to the following article:
Additional Dependencies of Aspose.Words

We suggest you please upgrade to the latest version of Aspose.Words for Java 17.2.0. If you still face problem, please share the requested detail here for testing. We will investigate the issue on our side and provide you more information.