Hello,
Very confusing error.
Aspose mail merge was working fine for me for months, I added a method to perform a simple merge and now nothing works. None of the fields in either array are null or empty (I printed them both out).
Can you please advise?
code:
String[] names =
{"EMAIL", "FIRM","MI","FAX","PHONE","TITLE", "FIRST", "MI", "LAST", "ADDRESS","LINE_2",
"CITY","STATE","ZIP","COUNTY","EFF_DATE","AOP1","AOP2","AOP4","AOP5","AOP6"};
Object[] obj = {"test@dpn.com",clientChkName, clientMName,clientFax, clientPhone ,"Sir",
clientFName , clientMName , clientLName ,cls(clientAddr.getAddress1()), cls(clientAddr.getAddress2()) ,cls(clientAddr.getCity()),
cls(clientAddr.getState()), zip, cls(clientAddr.getCounty()),appEffDate,"AOP1","AOP2","AOP4","AOP5","AOP6"};
System.out.println("Names:" + names.length + " Objs:" + obj.length);
for (int t = 0; t < names.length; t++)
{
System.out.println(names[t]);
System.out.println((String)obj[t]);
System.out.println();
}
try
{
doc = new Document(fileName);
System.out.println("filename::" + fileName);
// adding Merge Field Event Handler
doc.getMailMerge().addMergeFieldEventHandler(this);
doc.getMailMerge().execute(names, obj);
}
catch (Exception e) { System.out.println(e + "- MergeUtil error -"); e.printStackTrace(); }
ERROR GENERATED:
**filename::/opt/jakarta-tomcat-4.1.31/webapps/AMS_WEB/files/application_forms/ArchDoc.doc**
**java.lang.NullPointerException- MergeUtil error -**
**java.lang.NullPointerException**
**at com.aspose.words.hw.d(Unknown Source)**
**at com.aspose.words.hw.a(Unknown Source)**
**at com.aspose.words.MailMerge.execute(Unknown Source)**
**at com.aspose.words.MailMerge.execute(Unknown Source)**
**at com.core.beans.MergeUtil.executeAppMerge(MergeUtil.java:95)**
**at com.core.servlets.DocMergeServlet.doPost(DocMergeServlet.java:331)**
**at com.core.servlets.DocMergeServlet.doGet(DocMergeServlet.java:48)**
**at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)**
**at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)**
**at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)**
**at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)**
**at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)**
**at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)**
**at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)**
**at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)**
**at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)**
**at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)**
**at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)**
**at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)**
**at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)**
**at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)**
**at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)**
**at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)**
**at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)**
**at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)**
**at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)**
**at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)**
**at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)**
**at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)**
**at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)**
**at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)**
**at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)**
**at java.lang.Thread.run(Thread.java:534)**