背景:freemaker生成doc文档转PDF,PDF文档为0kb(表象)。之前的代码生成doc文档转为PDF后,删除doc文档,且异常处理的时候并未输出异常日志。导致生产问题一直定位不到原因,观察了好久。后来重新调整代码,优化异常处理,不删除doc文件,才定位到问题原因。
异常日志如下:
2020-03-27 09:50:42,316 [ERROR] [default task-44] c.c.m.modular.corpacct.service.impl.GenApplyFromServiceImpl [GenApplyFromServiceImpl.java : 1527] 表单出错:The document appears to be corrupted and cannot be loaded.
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.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.csii.mbdss.modular.corpacct.service.impl.GenApplyFromServiceImpl.doc2pdf(GenApplyFromServiceImpl.java:1524)
at com.csii.mbdss.modular.corpacct.service.impl.GenApplyFromServiceImpl.process(GenApplyFromServiceImpl.java:1469)
at com.csii.mbdss.modular.corpacct.service.impl.GenApplyFromServiceImpl.genBalanceAcctApplyForm(GenApplyFromServiceImpl.java:235)
at com.csii.mbdss.modular.corpacct.service.impl.GenApplyFromServiceImpl$$FastClassBySpringCGLIB$$4a604cb5.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.csii.mbdss.modular.corpacct.service.impl.GenApplyFromServiceImpl$$EnhancerBySpringCGLIB$$11b91c51.genBalanceAcctApplyForm(<generated>)
at com.csii.mbdss.modular.corpacct.controller.BuildMailController.build3Docs(BuildMailController.java:153)
at com.csii.mbdss.modular.corpacct.controller.BuildMailController.buildMailContent(BuildMailController.java:96)
at com.csii.mbdss.modular.corpacct.controller.BuildMailController$$FastClassBySpringCGLIB$$d8d5f68c.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.csii.mbdss.core.intercept.SessionInterceptor.sessionKit(SessionInterceptor.java:31)
at sun.reflect.G