Free Support Forum - aspose.com

CharsetProvider not found Exception

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)
at asposewobfuscated.rv.pl(Encoding.java:502)
at asposewobfuscated.rv.pi(Encoding.java:468)
at asposewobfuscated.rv.a(Encoding.java:452)
at asposewobfuscated.rv.m(Encoding.java:392)
at com.aspose.words.pa.a(FileFormatDetector.java:318)
at com.aspose.words.pa.aN(FileFormatDetector.java:304)
at com.aspose.words.pa.A(FileFormatDetector.java:44)
at com.aspose.words.Document.b(Document.java:1108)
at com.aspose.words.Document.a(Document.java:1084)
at com.aspose.words.Document.(Document.java:143)
at com.aspose.words.Document.(Document.java:120)
at de.hsp.maris.jangada.PDFCreator.createPDF(PDFCreator.java:199)
at de.hsp.maris.jangada.PDFCreator.createPDF(PDFCreator.java:249)
at de.hsp.maris.jangada.PDFCreator.createPDF(PDFCreator.java:756)
at de.hsp.maris.jangada.PDFCreator.run(PDFCreator.java:620)

Do you have any idea how to fix the problem?

Kind regards,
Frank

Hello

<?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?

Best regards,

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?

Hi

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:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/fileformatutil.html

Hope this helps.

Best regards,

Hi Frank,

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.

Best regards,

Hi,

this problem will also occur if the following java code is performed.
-> Charset.availableCharsets();

Error:
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.


Best regards
Matthias

Hi Matthias,

Thank you for additional information. We will let you know once the issue is resolved.

Best regards,

Hi Matthias,

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.

The issues you have found earlier (filed as WORDSJAVA-7) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(107)