javax.media.jai.util.ImagingException: All factories fail for the operation "stream"

Hi,

I tried to convert a mail to pdf using the code in the attachment. Aspose.Words fails with following Exception (with prerequisite JAI 1.1.3):

java.lang.Exception: javax.media.jai.util.ImagingException: All factories fail for the operation "stream"
at com.aspose.words.internal.zzN3.zzZ(Unknown Source)
at com.aspose.words.internal.zzN3.zzY(Unknown Source)
at com.aspose.words.internal.zzN3.zzZ(Unknown Source)
at com.aspose.words.internal.zzN3.zzY(Unknown Source)
at com.aspose.words.internal.zzYC.zzZ(Unknown Source)
at com.aspose.words.internal.zzYC.<init>(Unknown Source)
at com.aspose.words.internal.zzYC.<init>(Unknown Source)
at com.aspose.words.zzZNR.zzYM(Unknown Source)
at com.aspose.words.zzZNR.zz3(Unknown Source)
at com.aspose.words.zzZNR.setImageBytes(Unknown Source)
at com.aspose.words.ImageData.setImageBytes(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.zzZTX.zzZ(Unknown Source)
at com.aspose.words.zzZTX.zzZ(Unknown Source)
at com.aspose.words.zzZTX.zzz(Unknown Source)
at com.aspose.words.zzZTX.zzZ(Unknown Source)
at com.aspose.words.zzZTX.zzZ(Unknown Source)
at com.aspose.words.zzZTX.zzN(Unknown Source)
at com.aspose.words.zzZTX.zzO(Unknown Source)
at com.aspose.words.zzZTX.zzN(Unknown Source)
at com.aspose.words.zzZTX.zzO(Unknown Source)
at com.aspose.words.zzZTX.zzN(Unknown Source)
at com.aspose.words.zzZTX.zzO(Unknown Source)
at com.aspose.words.zzZTX.zzZ(Unknown Source)
at com.aspose.words.zzZGJ.zzT(Unknown Source)
at com.aspose.words.zzZGJ.zzY(Unknown Source)
at com.aspose.words.zzZGJ.zzZ(Unknown Source)
at com.aspose.words.zzZGJ.zzY(Unknown Source)
at com.aspose.words.zzZGJ.zzZ(Unknown Source)
at com.aspose.words.zzZGJ.zzZ(Unknown Source)
at com.aspose.words.zzZGM.read(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
[...]
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation "stream"
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1687)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2498)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
at com.aspose.words.internal.zzME.zzZ(Unknown Source)
at com.aspose.words.internal.zzN3.zzY(Unknown Source)
... 90 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
... 99 more
Caused by: com.sun.media.jai.codecimpl.util.ImagingException
at com.sun.media.jai.codecimpl.ImagingListenerProxy.errorOccurred(ImagingListenerProxy.java:63)
at 
com.sun.media.jai.codecimpl.GIFImageDecoder.decodeAsRenderedImage(GIFImageDecoder.java:177)
at com.sun.media.jai.codec.ImageDecoderImpl.decodeAsRenderedImage(ImageDecoderImpl.java:140)
at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:135)
... 105 more
Caused by: com.sun.media.jai.codecimpl.util.ImagingException: Error reading GIF image data.
... 108 more
Caused by: java.io.IOException: Error reading GIF image header.
at com.sun.media.jai.codecimpl.GIFImage.<init>(GIFImageDecoder.java:327)
at 
com.sun.media.jai.codecimpl.GIFImageDecoder.decodeAsRenderedImage(GIFImageDecoder.java:162)

Code + Mail: test.zip (601.1 KB)

The error is inside of JAI, but would it be possible to handle this error and generate a document without this gif?

Regards

@dvtdaten

We have tested the scenario using the latest version of Aspose.Email for Java 19.2 and Aspose.Words for Java 19.3 and have not found the shared issue. So, please use the latest version of Aspose products.

We use the versions you mentioned. Do you see 2 of 3 GIFs in output document? We include JAI 1.1.3 via Maven. I see 2 GIFs correct, the middle (hidden in Outlook) has a problem with rendering.

@dvtdaten

In your code, getDocLoadOptions() method exclude the images of .msg file. However, we have managed to reproduce the same exception while loading MHTML file generated by Aspose.Email.

For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-18329. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

We do not exclude images of msg file, we only exclude images loaded EXTERNAL in the msg file, because our server has no internet access and you will get timeouts. Images embedded in msg are displayed correct.

Thanks for working on that issue.

@dvtdaten

Thanks for sharing the detail. We will inform you once there is an update available on this issue.

The issues you have found earlier (filed as WORDSNET-18329) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.raza