执行文档时出现iText问题。关闭。。。不平衡的保存还原状态运算符

执行文档时出现iText问题。关闭。。。不平衡的保存还原状态运算符,itext,Itext,我们有一个应用程序,作为一个整体运行良好。 现在我们正在拆分应用程序 在这个过程中,我得到一个错误,如下所示。。。 这只发生在d.close()的位置 (作为一个整体,整个应用程序运行良好) (使用iText2.1.7 jar) 位于com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:241) 位于javax.rmi.CORBA.Util.mapSystemException(Util.java

我们有一个应用程序,作为一个整体运行良好。 现在我们正在拆分应用程序 在这个过程中,我得到一个错误,如下所示。。。 这只发生在d.close()的位置

(作为一个整体,整个应用程序运行良好) (使用iText2.1.7 jar)

位于com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:241)
位于javax.rmi.CORBA.Util.mapSystemException(Util.java:84)
retrieve(_fileName1Remote_Stub.java:1)
retrieve(fileName2.java:778)
at.onCustomAction1(fileName3.java:403)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)中
位于java.lang.reflect.Method.invoke(Method.java:611)
位于org.apache.el.parser.AstValue.invoke(AstValue.java:266)
位于org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
位于org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
位于javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:83)
... 43多
原因:com.itextpdf.text.exceptions.IllegalPdfSyntaxException:保存/还原状态运算符不平衡。 位于com.itextpdf.text.pdf.PdfContentByte.sanityCheck(PdfContentByte.java:3171) 位于com.itextpdf.text.pdf.PdfContentByte.toPdf(PdfContentByte.java:245) 请访问com.itextpdf.text.pdf.PdfFormXObject.(PdfFormXObject.java:88) 在com.itextpdf.text.pdf.PdfTemplate.getFormXObject上(PdfTemplate.java:241) 位于com.itextpdf.text.pdf.PdfWriter.addSharedObjectsToBody(PdfWriter.java:1257) 请访问com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1169) 请访问com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:780) 位于com.itextpdf.text.Document.close(Document.java:409) at.createPDF(.java:135) at.getPdfData(fileName1Bean.java:339) at.retrieve(fileName1Bean.java:205) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)中 位于java.lang.reflect.Method.invoke(Method.java:613) 位于com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:5730) 在com.ibm.ejs.container.interceptors.InvocationContextImpl.procedure(InvocationContextImpl.java:568) at.retrieveIntercept(.java:43) 位于sun.reflect.GeneratedMethodAccessor215.invoke(未知源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)中 位于java.lang.reflect.Method.invoke(Method.java:613) 在com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)上 在com.ibm.ejs.container.interceptors.InvocationContextImpl.procedure(InvocationContextImpl.java:548) 位于com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229) 位于com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:5621) 位于_c01dfd09.retrieve(EJSRemote0SLBean_c01dfd09.java) 在Bean\u c01dfd09\u Tie.retrieve(\u Bean\u c01dfd09\u Tie.java:1) 调用(_c01dfd09_Tie.java) 位于com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:669) 位于com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:523) 位于com.ibm.rmi.iiop.ORB.process(ORB.java:523) com.ibm.CORBA.iiop.ORB.process(ORB.java:1575) 位于com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:3039) 位于com.ibm.rmi.iiop.Connection.doWork(Connection.java:2922) 位于com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64) 位于com.ibm.ws.giop.threadpool.WorkQueueElement.dispatch(WorkQueueElement.java:165) 位于com.ibm.ws.giop.filter.GiopFilterChain.processMessage(GiopFilterChain.java:203) 位于com.ibm.ws.giop.threadpool.PooledThread.handleRequest(PooledThread.java:81) 位于com.ibm.ws.giop.threadpool.PooledThread.run(PooledThread.java:102) 在com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)

这里是。。。 首先,如果我的问题有歧义,我道歉。 如上所述,还使用了2.1.7版(多亏了Amedee的观点)。我在服务器的共享库中找到了一个5.x版本。 由于两个版本之间的目录结构完全不同,因此两个JAR都是出于特定原因而维护的

此外,我本人对整个应用程序还不熟悉,并试图与项目中的人取得了解。当开发它的人可能不在这里时,我想一篇帖子可能会给我一些想法。所以,你也有一部分是对的,洛瓦吉先生-我对iText一无所知,我也在学习-我没有理由撒谎!:-)

Mkl,try块中没有异常。最终的结果是,由于其他原因,图像没有生成或被篡改。目前正在进行调查。我把这个活动交给了一个比我更了解这个系统的人


感谢你所有的邮件和支持我亲爱的朋友们

你的问题有点不对劲。您说您使用的是古老的iText版本2.1.7(2009年7月7日发布),因此您的代码中有
com.lowagie
,但您的错误消息中提到
com.itextpdf
,它只存在于从5.0.0开始的iText版本中。也许您的构建路径中有多个iText jar?异常说明您在代码中编写了一个bug。由于您没有显示代码,我们无法准确地告诉您做错了什么。我们只能告诉您,您没有为每个
saveState()
使用
restoreState()
,或者您使用的
restoreState()
没有
s
Document d = new Document(PageSize.A4, 10, 10, 50, 50);
......
.....
finally{
            if(d.isOpen()) {
                d.close();
            }
            byteOutputStream.flush();
            byteOutputStream.close();
            pw.close();
            return byteOutputStream.toByteArray();
        }
at com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:241)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:84)
at <<stub path>>.retrieve(_fileName1Remote_Stub.java:1)
at <<filePath>>.retrieve(fileName2.java:778)
at <<filePath>>.onCustomAction1(fileName3.java:403)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.apache.el.parser.AstValue.invoke(AstValue.java:266)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:83)
... 43 more