javax.imageio.IIOException: Inconsistent metadata read from stream

I am getting a “javax.imageio.IIOException: Inconsistent metadata read from stream” exception in the log but Aspose.Words is not throwing an error up to my code so my code thinks everything is fine, and as far as I can tell, it is.
I am trying to convert an RTF document to a PDF and it has a JPEG image in it that has CMYK color encoding.
I am using Aspose.Words. 13.5.
I am using JRE: Java Runtime: Java™ SE Runtime Environment (build 1.6.0_43-b01)
When I run this code as a simple test Java application it just works. When I put the code in to my Web application running under JBoss 5.2.3 I get this exception in the log but nothing thrown at my code. The PDF is created and the image is in the PDF. If I hadn’t been looking at the logs I never would have known there was a problem and I am still not sure there really is a problem. I have attached the RTF document as a zip file and here is the trace:

15:32:58,193 ERROR [STDERR] javax.imageio.IIOException: Inconsistent metadata read from stream
15:32:58,194 ERROR [STDERR] at com.sun.imageio.plugins.jpeg.JPEGMetadata.(JPEGMetadata.java:343)
15:32:58,194 ERROR [STDERR] at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageMetadata(JPEGImageReader.java:933)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.rm.a(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.rl.a(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.rl.o(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.rl.(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.uh.tu(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.uh.h(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.uh.b(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.ux.a(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.ux.j(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.ur.b(Unknown Source)
15:32:58,194 ERROR [STDERR] at asposewobfuscated.st.b(Unknown Source)
15:32:58,195 ERROR [STDERR] at asposewobfuscated.sz.endDocument(Unknown Source)
15:32:58,195 ERROR [STDERR] at asposewobfuscated.uv.endDocument(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.amm.UR(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.qt.a(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.Document.a(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.Document.a(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.Document.h(Unknown Source)
15:32:58,195 ERROR [STDERR] at com.aspose.words.Document.save(Unknown Source)

Hi Scott,

Thanks for your inquiry.

Most of our Java products depend upon the JAI package (Java Advanced Imaging)
from Sun in order to process images. By looking at the stack trace, it
seems your problem is somehow related to JAI. Please configure JAI
package on your side, you can find jai 1.1.3 and jai-imageio 1.1 in the
following links:

https://docs.aspose.com/words/java/system-requirements/#optional-dependencies

I would suggest you please upgrade to the latest version (v13.10.0) from here and let us know how it goes on your side. Hope this helps you.

If the problem still remains, please share following detail for investigation purposes.
What environment are you running on?

  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • Java version

Please also try to save the Rtf to Doc file format and then save the output Doc file to Pdf. Please share your finding here for our reference. We will then provide you more information on this.

Thanks, I will give that a try.

Hi Scott,

Further to my last post, I have tested this issue at Windows 7 (64 bit), JBoss AS 7.1.1, Jdk 1.6 and latest version of Aspose.Words for Java 13.10.0 and have not found any exception. I have attached the output Pdf file with this post for your kind reference.

Please let us know if you face any issue while using latest version of Aspose.Words for Java 13.10.0.

I am using Words 13.5 and JBoss 5.2.3. I haven’t had a chance to copy in the libraries and see if it makes a difference.
Poking around Oracle’s site seems to indicate that the image libraries are not being actively supported anymore and it looks like nothing has been done with them since about 2007. Did these libraries land someplace else?

Hi Scott,

Thanks for your inquiry.

Please configure JAI
package on your side, you can find jai 1.1.3 and jai-imageio 1.1 in the
following links:

https://docs.aspose.com/words/java/system-requirements/#optional-dependencies

Please also upgrade to the latest version of Aspose.Words for Java 13.10.0 and let us know how it goes on your side.

If you still face problem, please share following detail for investigation purposes.
What environment are you running on?

  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • Java version

We will prepare the required platform to
simulate the environment as of yours and will test the shared issue.

I wanted to provide a correction for the version of JBoss I am working with. It is 5.1.0, not 5.2.3. Sorry for the confusion.

Hi Scott,

Thanks for sharing the detail. I have logged a new Task in our issue tracking system as WORDSJAVA-816 to investigate the shared issue. I will setup the JBoss v5.1.0 at my side and will test the shared issue. I will post the results here for your kind reference asap.

As suggested earlier, please try the latest version (v13.10.0) from here and let us know how it goes on your side.

Thank you for your patience and understanding.

Hi Scott,

Thanks for your patience.

I have tested the scenario at JBoss 5.1.0 and have not found any exception while using latest version of Aspose.Words for Java 13.10.0. I have attached the output Pdf file with this post for your kind reference. Please use the latest version of Aspose.Words for Java and let us know if you have any more queries.

I tried 13.10 and it did not reproduce. However, I tried 13.5 again and I couldn’t get it to reproduce either. At this point I have no idea why that was happening to me. It was reproducing both standalone and through Eclipse, under debug and normal. Today however, I can’t get it to reproduce. I can only assume that something else I was running at the time or had run and altered the environment was causing it. As of right now, it works fine.
Thanks for your help.

Hi Scott,

Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please let us know if you face any issue while using Aspose.Words, we will be happy to help you.