Specified argument was out of the range of valid value for Aspose Total while getting word count

Hi ,
we have valid OEM licence for aspose total

we have dependecy defined as

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-total</artifactId>
    <version>23.8</version>
    <type>pom</type>
</dependency>

we have our code as

  public WordCountDetails getWordCountFromStream(InputStream file) {
        int wordCount = 0;
        int pageCount = 0;

        try(file) {
            com.aspose.words.Document document = new com.aspose.words.Document(file);
            WordCountDetails wordCountDetails = new WordCountDetails();

            document.setIncludeTextboxesFootnotesEndnotesInStat(true);
            document.updateWordCount(true);

            wordCount = document.getBuiltInDocumentProperties().getWords();
            pageCount = document.getBuiltInDocumentProperties().getPages();

            wordCountDetails.setWordCount(wordCount);
            wordCountDetails.setPageCount(pageCount);
            return wordCountDetails;
        }  catch (Exception e) {
            LOGGER.error("Aspose Exception: " ,e);
            throw new AsposeException(e.getMessage());
        }
    }

Strange thing is it works fine in local env but fails in UAT and Prod for attached files , it works fine for other files

it is failing with below exception in deployed env , Kindly Assist

chapter 5.docx (72.3 KB)

ETMsurge_CRCBookChapter_2.docx (60.6 KB)

ETMsurge_CRCBookChapter_3.docx (76.6 KB)

chapter 3.docx (59.0 KB)

java.lang.IllegalArgumentException: Specified argument was out of the range of valid values.
Parameter name: index
        at com.aspose.words.internal.zzVUu.zzLF(Unknown Source)
        at com.aspose.words.internal.zzX2j.zzVSm(Unknown Source)
        at com.aspose.words.internal.zzX2j.zzVSm(Unknown Source)
        at com.aspose.words.internal.zzZL.zzVSm(Unknown Source)
        at com.aspose.words.internal.zzWAb.zzZBg(Unknown Source)
        at com.aspose.words.internal.zzWAb.zzX2P(Unknown Source)
        at com.aspose.words.internal.zzWAb.<init>(Unknown Source)
        at com.aspose.words.internal.zzWAb.<init>(Unknown Source)
        at com.aspose.words.zzHk.zzVSm(Unknown Source)
        at com.aspose.words.zzYtS.zzpm(Unknown Source)
        at com.aspose.words.zzYtS.zzXju(Unknown Source)
        at com.aspose.words.zzZca.zzCi(Unknown Source)
        at com.aspose.words.zzYtS.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzZca.zzXju(Unknown Source)
        at com.aspose.words.zzZca.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzZca.zzXju(Unknown Source)
        at com.aspose.words.zzZca.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzXhc.zzXDo(Unknown Source)
        at com.aspose.words.zzXhc.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzZca.zzXju(Unknown Source)
        at com.aspose.words.zzZca.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzZca.zzXju(Unknown Source)
        at com.aspose.words.zzZca.zzCi(Unknown Source)
        at com.aspose.words.zzZca.zzHM(Unknown Source)
        at com.aspose.words.zzYCR.zzX30(Unknown Source)
        at com.aspose.words.zzY.zzZ0Y(Unknown Source)
        at com.aspose.words.zzY.zzWte(Unknown Source)
        at com.aspose.words.zzY.zzYRc(Unknown Source)
        at com.aspose.words.zzYTI.zzVV6(Unknown Source)
        at com.aspose.words.zzY.getWidth(Unknown Source)
        at com.aspose.words.zzXJb.zzYVL(Unknown Source)
        at com.aspose.words.zzZqo.zzWW4(Unknown Source)
        at com.aspose.words.zzXyh.zzWgv(Unknown Source)
        at com.aspose.words.zzXyh.zzQF(Unknown Source)
        at com.aspose.words.zzXyh.zzWqn(Unknown Source)
        at com.aspose.words.zzzW.zzVSm(Unknown Source)
        at com.aspose.words.zzzW.zzwW(Unknown Source)
        at com.aspose.words.zzZfr.zzYUE(Unknown Source)
        at com.aspose.words.zzZfr.zzXdb(Unknown Source)
        at com.aspose.words.zzWKz.zzZiN(Unknown Source)
        at com.aspose.words.zzWKz.zzV3(Unknown Source)
        at com.aspose.words.zzWKz.zzWsW(Unknown Source)
        at com.aspose.words.zzWwn.zzWPk(Unknown Source)
        at com.aspose.words.zzWwn.zzWsW(Unknown Source)
        at com.aspose.words.zzHm.zzZuA(Unknown Source)
        at com.aspose.words.zzHm.zzV3(Unknown Source)
        at com.aspose.words.zzHm.zzVSm(Unknown Source)
        at com.aspose.words.zzXyy.zzZY0(Unknown Source)
        at com.aspose.words.zzXyy.zzQF(Unknown Source)
        at com.aspose.words.zzXyy.zzV3(Unknown Source)
        at com.aspose.words.zzWFy.zzZ15(Unknown Source)
        at com.aspose.words.zzWFy.zzMU(Unknown Source)
        at com.aspose.words.zzWFy.zzXDk(Unknown Source)
        at com.aspose.words.zzWFy.zzZyt(Unknown Source)
        at com.aspose.words.zzXI4.zzZyt(Unknown Source)
        at com.aspose.words.zzYgI.zzWsW(Unknown Source)
        at com.aspose.words.zzYl7.zzQx(Unknown Source)
        at com.aspose.words.zzZ1n.zzXs4(Unknown Source)
        at com.aspose.words.Document.updatePageLayout(Unknown Source)
        at com.aspose.words.Document.zzYoM(Unknown Source)
        at com.aspose.words.Document.getPageCount(Unknown Source)
        at com.aspose.words.zzW5P.zzWsW(Unknown Source)
        at com.aspose.words.zzW5P.zzVSm(Unknown Source)
        at com.aspose.words.zzZOH.zzVSm(Unknown Source)
        at com.aspose.words.Document.zzWsW(Unknown Source)
        at com.aspose.words.Document.zzVSm(Unknown Source)
        at com.aspose.words.Document.zzVSm(Unknown Source)
        at com.aspose.words.Document.updateWordCount(Unknown Source)
        at uk.co.tandf.metadata.utils.AsposeUtilities.getWordCountFromStream(AsposeUtilities.java:1030)
        at uk.co.tandf.metadata.service.impl.ContentProcessingServiceImpl.getWordCountFromWordFile(ContentProcessingServiceImpl.java:326)
        at uk.co.tandf.metadata.controller.ContentProcessingServiceController.getWordCount(ContentProcessingServiceController.java:129)
        at uk.co.tandf.metadata.controller.ContentProcessingServiceController$$FastClassBySpringCGLIB$$3dd005ad.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:120)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
        at uk.co.tandf.metadata.controller.ContentProcessingServiceController$$EnhancerBySpringCGLIB$$3ba9c985.getWordCount(<generated>)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:760)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1617)
        at com.tandf.interceptor.generic.RequestCachingFilter.doFilter(RequestCachingFilter.java:41)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
        at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:545)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1592)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1296)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1562)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1211)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:500)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:386)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:562)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:378)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:388)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
        at java.base/java.lang.Thread.run(Unknown Source)
08:41:04.477 [qtp1462144963-72] ERROR u.c.t.m.c.ContentProcessingServiceController - error while calculating word count Specified argument was out of the range of valid values.
Parameter name: index

@Nikhil_Kamani Unfortunately, I cannot reproduce the problem on my side with neither of the attached documents. Could you please describe the environment where the problem is reproducible? We will try to recreate the same environment on our side.
Also, please try using the latest 24.4 version of Aspose.Words for Java.

Seems this is working fine with new version of Aspose, we will do final confirm and write back

1 Like