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

Free Support Forum - aspose.com

Mail Merge Word Template Document using Java | Build Report | Avoid String Index Out Of Bounds Exception

we got two exception, the java stack below, we don’t know why, could you please help us(Aspose15.20(JDK))
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at com.aspose.words.zzZT.zzZ(Unknown Source)
at com.aspose.words.zzZT.zzZ(Unknown Source)
at com.aspose.words.zz55.zzZ(Unknown Source)
at com.aspose.words.FieldFormula.zzRX(Unknown Source)
at com.aspose.words.FieldFormula.zzZXp(Unknown Source)
at com.aspose.words.zz2F.zzH(Unknown Source)
at com.aspose.words.zz2F.zzJ(Unknown Source)
at com.aspose.words.zz2F.zzN(Unknown Source)
at com.aspose.words.zz2F.zzQ(Unknown Source)
at com.aspose.words.zz2F.zzS(Unknown Source)
at com.aspose.words.zz2F.zzV(Unknown Source)
at com.aspose.words.zz2F.zzZh(Unknown Source)
at com.aspose.words.zz2F.zzx(Unknown Source)
at com.aspose.words.zzZN3.zzZ(Unknown Source)
at com.aspose.words.zzZN3.zzZCj(Unknown Source)
at com.aspose.words.zzZN3.zzZ(Unknown Source)
at com.aspose.words.MailMerge.zzZ(Unknown Source)
at com.aspose.words.MailMerge.execute(Unknown Source)

Caused by: java.lang.ClassCastException: com.aspose.words.zzZ9N cannot be cast to com.aspose.words.zzZTF
at com.aspose.words.zz52.zzZ(Unknown Source)
at com.aspose.words.zz52.zzZYf(Unknown Source)
at com.aspose.words.zz52.zzY(Unknown Source)
at com.aspose.words.zz53.zzZ(Unknown Source)
at com.aspose.words.zz53.zzRX(Unknown Source)
at com.aspose.words.zzWZ.zzZ(Unknown Source)
at com.aspose.words.zzWZ.zzZ(Unknown Source)
at com.aspose.words.FieldIf.zzZVD(Unknown Source)
at com.aspose.words.FieldIf.zzZ(Unknown Source)
at com.aspose.words.zz2F.zzT(Unknown Source)
at com.aspose.words.zz2F.zzU(Unknown Source)
at com.aspose.words.zz2F.zzV(Unknown Source)
at com.aspose.words.zz2F.zzU(Unknown Source)
at com.aspose.words.zz2F.zzV(Unknown Source)
at com.aspose.words.zz2F.zzZh(Unknown Source)
at com.aspose.words.zz2F.zzx(Unknown Source)
at com.aspose.words.zzZN3.zzZ(Unknown Source)
at com.aspose.words.zzZN3.zzZCj(Unknown Source)
at com.aspose.words.zzZN3.zzZ(Unknown Source)
at com.aspose.words.MailMerge.zzZ(Unknown Source)
at com.aspose.words.MailMerge.execute(Unknown Source)

@lu.zhiguo.zuora,

Please ZIP and attach the following resources here for testing:

  • Your simplified template Word document
  • Your expected DOCX file showing the desired output. You can create this document manually by using MS Word.
  • Please also create a standalone simple Java application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your particular scenario/issue and provide you more information.

this was happened in our production, i can not reproduced it with that template in my local, but I want to know what will cause above exception.

@lu.zhiguo.zuora,

It seems that you are using a very old 15.2 version of Aspose.Words for Java API on your end. Have you also tried the latest (20.9) version of Aspose.Words for Java on your end? In case the problem still remains with 20.9 version, then we need the resources mentioned in my previous post to be able to reproduce and fix the problem on our end.