Dear Aspose Team,
I downloaded the newest Version of Aspose.Words for Java and I got the following Exception when calling the “new Document(source)” method:
Exception in thread “PDFCreator” sun.misc.ServiceConfigurationError: java.nio.charset.spi.CharsetProvider: Provider com.aspose.ms.java.utf7charset.provider.CharsetProvider not found
at sun.misc.Service.fail(Unknown Source)
at sun.misc.Service.access$000(Unknown Source)
at sun.misc.Service$LazyIterator.next(Unknown Source)
at java.nio.charset.Charset$1.getNext(Unknown Source)
at java.nio.charset.Charset$1.hasNext(Unknown Source)
at java.nio.charset.Charset$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.charset.Charset.lookupViaProviders(Unknown Source)
at java.nio.charset.Charset.lookup2(Unknown Source)
at java.nio.charset.Charset.lookup(Unknown Source)
at java.nio.charset.Charset.forName(Unknown Source)
Do you have any idea how to fix the problem?
Dear Aspose Team,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. Could you attach the document you are getting problem with? Or the problem occurs with any document you try?
After 4 hours of debugging I found the problem! When opening a file, that is not a word document (e.g. a PDF) with the method “new Document(source)”, you will geht this exception!
Is it possilbe to return null instead of this exception?
Thanks for your request. The behavior is correct, an exception should be thrown if you attempt to open file in unsupported format. But this should be UnsupportedFileFormatException. I logged this problem into our defect database. We will let you know once it is resolved.
I think, in your case, you can try using FileFormatUtil to determine format of the file before opening it. In this case, you will be able to sort out files in not supported formats:
Hope this helps.
Just checked with FileFormatUtil and got the same exception. So this seems to be the same problem. We will let you know once it is resolved.
this problem will also occur if the following java code is performed.
Exception in thread “main” sun.misc.ServiceConfigurationError: java.nio.charset.spi.CharsetProvider: Provider com.aspose.ms.java.utf7charset.provider.CharsetProvider not found
I think we found the reason for the problem.
The file ‘java.nio.charset.spi.CharsetProvider’ (located in ‘Aspose.Words.jar\META-INF\services’) contains the class entry ‘com.aspose.ms.java.utf7charset.provider.CharsetProvider’. This class is missing in Aspose 10.1.0)
Aspose 4.0.3 does contain the service file ‘java.nio.charset.spi.CharsetProvider’ too. But it contains the class entry
‘com.aspose.words.CharsetProvider’. This class does exist in Aspose 4.0.3. Therfore no error will occur.
The problem in Aspose 10.1.0 will not occur anymore, if directory ‘services’ is deleted within the jar-file.
Thank you for additional information. We will let you know once the issue is resolved.
Thank you for such a detailed analysis of the problem.
Aspose.Words supports UTF7 encodings for reading/writing documents and this encoding is not natively supported by Java. Hence Aspose.Words implements its own charset and charset provider and it appears the class has somehow been left out or incorrectly linked into the final jar.
We will fix this issue asap. But since it does not appear that is causing you a major problem now (correct me if I'm wrong) it will go into the scheduled 10.2 release at the end of June.