We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error converting html file in Java WebStart (JNLP) application


We developed an application that is provided to the end user with Java WebStart.

During our tests we obtained the following exception while reading an html file:

Caused by: com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.Document.a(Document.java:1376)
at com.aspose.words.Document.b(Document.java:1363)
at com.aspose.words.Document.a(Document.java:1251)
at com.aspose.words.Document.(Document.java:248)
at com.aspose.words.Document.(Document.java:232)
at com.aspose.words.Document.(Document.java:227)
… 8 more
Caused by: java.lang.IllegalStateException: java.nio.charset.UnsupportedCharsetException: UTF-7
at asposewobfuscated.mg.vr(Encoding.java:482)
at asposewobfuscated.mg.vn(Encoding.java:241)
at asposewobfuscated.mg.U(Encoding.java:460)
at com.aspose.words.hb.iM(FileFormatDetector.java:246)
at com.aspose.words.hb.g(FileFormatDetector.java:38)
at com.aspose.words.Document.b(Document.java:1267)
… 12 more
Caused by: java.nio.charset.UnsupportedCharsetException: UTF-7
at java.nio.charset.Charset.forName(Unknown Source)
at asposewobfuscated.mg.vr(Encoding.java:478)
… 17 more

In our understanding this exception is thrown as a consequence of the Aspose Words library not having the UTF-7 Charset available during an NIO operation.

After investigating we found what this is caused by what is considered a bug in the sun virtual machine, which is the fact that the Charset class load is done with the system classloader and not the thread context classloader. Given the fact that we are using Java WebStart, the System ClassLoader is not the same that is used to execute the application, thus causing it to fail (documented in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4619777).

Are there any plans to change Aspose Words in order to replace the usage of the com.aspose.words.CharsetProvider class with any other approach?

This is a very critical issue for us because right now we are almost ready (at least we thought so) to deploy the application in production, but now because of this issue we are unable to do so.

Kind Regards and Thanks in advance,
António Lourinho

Hi Antonio,

Try using this code in your project instead.

InputStream is = new ByteArrayInputStream(html.getBytes());
Document doc = new Document(is,"",LoadFormat.HTML,"");
doc.save("document out.doc", SaveFormat.DOC);

It seems this code worked as a work around in a similar problem to do with Java WebStart. If that still does not resolve the issue could you please create a small test application that demonstrates the problem so we can reproduce it and take a look?



The code you provided solved the problem.

Thanks a lot,
António Lourinho