Issue opening a document using com.aspose.words.Document

Hi guys,

We use aspose as a part of a internal library to open/modify word documents.

We have a customer that is using our product with Windows 10 and basically we use:

input = new FileInputStream(file);
com.aspose.words.Document doc = new com.aspose.words.Document(
input);
input.close();

And we get the following error stacktrace:

com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.ibm.rdm.fronting.server.rrs.publish.internal.LegacyPublishService.customizeStylesheet(LegacyPublishService.java:3236)
at com.ibm.rdm.fronting.server.rrs.publish.internal.LegacyPublishService.initPublishing(LegacyPublishService.java:3179)
at com.ibm.rdm.fronting.server.rrs.publish.internal.LegacyPublishService.doInitialize(LegacyPublishService.java:2972)
at com.ibm.rdm.fronting.server.rrs.publish.internal.LegacyPublishService.doGet(LegacyPublishService.java:609)
at com.ibm.rdm.fronting.server.rrs.publish.internal.PublishServiceInternal.doGetInternal(PublishServiceInternal.java:87)
at com.ibm.rdm.fronting.server.core.internal.RRSRestServiceBase.runInternalMethod(RRSRestServiceBase.java:698)
at com.ibm.rdm.fronting.server.core.internal.RRSRestServiceBase.handleMethod(RRSRestServiceBase.java:587)
at com.ibm.rdm.fronting.server.core.internal.RRSRestServiceBase.doGet(RRSRestServiceBase.java:130)
at com.ibm.rdm.fronting.server.core.internal.RRSRestServiceBase.performService(RRSRestServiceBase.java:360)
at com.ibm.rdm.fronting.server.rrs.publish.PublishService.performService(PublishService.java:100)
at com.ibm.rdm.fronting.server.core.internal.RRSRestServiceBase.service(RRSRestServiceBase.java:208)
at com.ibm.team.jfs.app.servlet.AppContainerServlet.dispatchRequest(AppContainerServlet.java:155)
at com.ibm.team.jfs.app.servlet.AppContainerServlet.service(AppContainerServlet.java:282)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleAppSdkRestServiceRequest2(AbstractTeamServerServlet.java:2110)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.access$2(AbstractTeamServerServlet.java:2055)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet$2.service(AbstractTeamServerServlet.java:271)
at com.ibm.team.repository.service.internal.oauth.OAuthServiceProvider$2.run(OAuthServiceProvider.java:327)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleAuthentication(AbstractTeamServerServlet.java:2166)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleAppSdkRestServiceRequest(AbstractTeamServerServlet.java:2031)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1768)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:152)
at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:74)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1255)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:743)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:440)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:147)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.team.repository.server.servletbridge.BridgeFilter.processDelegate(BridgeFilter.java:165)
at com.ibm.team.repository.server.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:198)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:995)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1124)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4962)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:314)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:995)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1009)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:412)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:371)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:530)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:464)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:329)
at com.ibm.ws.http.channel.internal.inbound.HttpICLReadCallback.complete(HttpICLReadCallback.java:70)
at com.ibm.ws.channel.ssl.internal.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1803)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:501)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:571)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:926)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1015)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.NullPointerException
at com.aspose.words.zzZ00.zzZmS(Unknown Source)
at com.aspose.words.zzZ00.zzZmU(Unknown Source)
at com.aspose.words.zzZ00.zzz4(Unknown Source)
at com.aspose.words.zz5.zzTX(Unknown Source)
at com.aspose.words.zz5.zzTY(Unknown Source)
at com.aspose.words.zzZ00.zzZmY(Unknown Source)
at com.aspose.words.zzZ00.zzZ(Unknown Source)
at com.aspose.words.zz99.visitSectionStart(Unknown Source)
at com.aspose.words.Section.zzZ(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Section.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Document.accept(Unknown Source)
at com.aspose.words.zz99.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
… 64 more

I’m almost sure that his is not a directly issue with Aspose since we have other customers without any problem but wanted to know if you have a reference about problem with permissions folder where the documents are stored.

We are using right now: aspose-words-17.11-jdk16.jar

Do you know if there is a problematic issue with this jar using windows 10 or something related to the OS or any other suggestion?

@aldog,

Please ZIP and attach your input Word document you are getting this problem with here for testing. We will then investigate the issue on our end and provide you more information.

Hi Awais,

Thanks for your answer, I think the issue is not related to the document itself, it is more a permission issue since we have exactly the same environment with other customers and they are not facing the issue.

I’m attaching the word document but would like to know there is a specific configuration of permissions that resulted in the mentioned stacktrace.

Thanks for your help´!audithistory word.zip (6.1 KB)

@aldog,

After an initial test with the licensed latest version of Aspose.Words for Java i.e. 19.3, we were unable to reproduce this issue on our end. We would suggest you please upgrade to the latest version of Aspose.Words for Java on your end. Hope, this helps.

Awais, really appreciate your help.

We tried as well with latest version with the same document and the same issue is happening, I think this is more related to a permission issue rather than a version issue, do you have an idea of possible scenario that might trigger this ?

@aldog,

Aspose.Words needs to pre-cache fonts and other resources for rendering. Please make sure that the app hosted in server has access to Fonts installation directory.

P.S. you may please also check this article (True Type Fonts).

Thank you awais, this opens new theory of investigation but I think the issue is at the moment of saving the stylesheet but we will keep investigating.

If you have any other suggestion to try regarding the save option, that would be awesome!

Really appreciate your help!

@aldog,

Unfortunately, your question is not clear enough therefore we request you to please elaborate your inquiry further by providing complete details of the issue you are getting with the style sheet. Please ZIP and upload your sample Word document and Aspose.Words generated output document showing the undesired behavior here for testing. This will help us to understand your scenario, and we will be in a better position to address your concerns accordingly.

Hi Awais,

Sorry if I missunderstood =)

Basically we have a customer that is working on Windows 10, The customer is using the file that I provided initially on this thread, see my second post.

Basically we use the following code

input = new FileInputStream(file);
com.aspose.words.Document doc = new com.aspose.words.Document(
input);

To read from that document, the issue here is that all of our customers doesn’t have any problem with this instruction, only this customer.

As metioned, the stack is throwing the exception:

com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.zzZ(Unknown Source)

so would like to know, under which circumstances, FileFormatUtil, can throw a FileCorruptedException?

@aldog,

Please also test the scenario with the old Aspose.Words for Java 19.2 on your side and see if the problem goes away?

Please also share your environment details e.g. OS, JDK versions. Thanks for your cooperation.

Hi Awais,

I really appreciate your help, yesterday I found what is going on.

The user was using an incorrect Locale in their server. Not sure if it is reproducible in the last version but you can try:

System.out.println(System.getProperty(“java.io.tmpdir”));
try {
Locale.setDefault(new Locale(“pl”, “PLs”));
File file = new File (“C:\Users\aldo_alcala\Documents\PSL\Escalations\86381 Generating report for module\3- word\word\audithistory.doc\”);
FileInputStream input = null;
//FileFormatInfo info = FileFormatUtil
// .detectFileFormat(file.getAbsolutePath());
// Note that this setting will override any default font sources that are being searched by default. Now only these folders will be searched for
// fonts when rendering or embedding fonts. To add an extra font source while keeping system font sources then use both FontSettings.GetFontSources and
// FontSettings.SetFontSources instead.
input = new FileInputStream(file);
com.aspose.words.Document doc = new com.aspose.words.Document(input);
input.close();
doc.save(file.getAbsolutePath());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch blockj
e.printStackTrace();
}

@aldog,

We have logged your problem in our issue tracking system. Your ticket number is WORDSJAVA-2014. We will further look into the details of this problem and will keep you updated on the status of the linked issue.

Awais,

Really appreciate and awesome support guys!

Regards!

The issues you have found earlier (filed as WORDSJAVA-2014) have been fixed in this Aspose.Words for .NET 19.4 update and this Aspose.Words for Java 19.4 update.