2017-10-10 3 views
1

私は、コールリモートビジネスインタフェースによってインターネット経由でiTextPdf 7.0.4で作成されたpdfを提供するためにEJBを使用しています。EJBはPDFを返します。再要求オブジェクトが他のPDF例外に属します

マイEJBサーバ側として実装:サーバーが実装

@Override 
public byte[] renderBillById(String billId) { 
    logger.info("rendering bill pdf called in EJB Model."); 
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
    PdfWriter writer = new PdfWriter(baos); 
    PdfDocument pdf = new PdfDocument(writer); 
    Document document = new Document(pdf, PageSize.A4); 
    document.setMargins(20, 20, 20, 20); 

    fetchBillContext(billId); 

    document.add(billHeaderTable()); 
    document.add(billReceiverTable()); 
    document.add(billBalanceTable()); 
    document.add(summaryOuterTable()); 
    document.add(howToPay()); 
    document.add(notesPara()); 
    document.add(payOptionsTable()); 

    document.close(); 
    return baos.toByteArray(); 
} 

は、PDFを生成しますし、私はバイト配列の形式でそれを必要とします。私はバイト配列をWebサーバー(JSFページのサーバーにコントローラを使用してWebサーバーで呼び出す)にリクエストし、リモートEJBクライアント(RMIで呼び出す)にリクエストしてみましたが、同じ結果が得られました。

com.itextpdf.kernel.PdfException: Pdf indirect object belongs to other PDF document. Copy object to current pdf document. 

詳細:私は再びそれを呼び出すしようとしたときに一度、EJBサーバは、次の例外がスローされます

javax.ejb.EJBException: EJB Exception: ; nested exception is: 
com.itextpdf.kernel.PdfException: Pdf indirect object belongs to other PDF document. Copy object to current pdf document. 
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:127) 
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:94) 
at com.sun.proxy.$Proxy306.renderBillById(Unknown Source) 
at com.longz.ozssc.web.staff.BillControlBean.viewBillInPdf(BillControlBean.java:191) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at javax.el.ELUtil.invokeMethod(ELUtil.java:304) 
at javax.el.BeanELResolver.invoke(BeanELResolver.java:535) 
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256) 
at com.sun.el.parser.AstValue.invoke(AstValue.java:285) 
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) 
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) 
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) 
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) 
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) 
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) 
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87) 
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) 
at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45) 
at javax.faces.component.UICommand.broadcast(UICommand.java:315) 
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) 
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) 
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) 
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:650) 
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286) 
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260) 
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137) 
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350) 
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78) 
at com.longz.ozssc.web.staff.misc.NoCacheFilter.doFilter(NoCacheFilter.java:28) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78) 
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32) 
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78) 
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683) 
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649) 
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326) 
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197) 
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203) 
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71) 
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433) 
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281) 
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259) 
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691) 
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651) 
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270) 
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348) 
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333) 
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54) 
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41) 
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640) 
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406) 
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346) 
Caused By: com.itextpdf.kernel.PdfException: Pdf indirect object belongs to other PDF document. Copy object to current pdf document. 
at weblogic.utils.StackTraceDisabled.unknownMethod() 

サーバー側の例外は、いくつかのオブジェクト参照の問題を持っているように見えます。

私はスタックオーバフローで同様の問題を発見しようとしましたが、そのほとんどはPdfFontの問題ですが、私の場合はPdfFontを使用しませんでした。

誰にも問題がありますか?あなたが持っている場合。どうやってそれを修正するのですか?

+1

これは、 'document.add'呼び出しで参照するメソッドのいずれかで問題になる可能性がありますので、' billHeaderTable() 'とそれに類似したメソッドのコードを共有してください。 – blagae

+0

PDFドキュメントにPdfFontオブジェクトを使用しないでください。それが私が非常に混乱している理由です。 –

答えて

0

iText 7 Building Blocksチュートリアルのchapter 1にアクセスしてください。エラーメッセージ:

Pdf間接的なオブジェクトは他のPDFドキュメントに属しています。オブジェクトを現在のpdfドキュメントにコピーします。

あなたがあることを発見する

が最初に作成されたPDFに属しPdfFontインスタンスを使用しようとする...

あなたは章を読めばあなたはその違いについて学びます

  • FontProgramオブジェクト、フォントオブジェクトtha 1つのインスタンスを作成し、PDfを作成するたびに再利用されます。
  • PdfFontオブジェクト、作成する各PDFに固有のフォントオブジェクト、を作成するたびにをインスタンス化する必要があります。

blagaeによって示されるように、エラーがどこかbillHeaderTable()billReceiverTable()、...方法です。

+0

ありがとう!メイト。 PDFドキュメントでPdfFontオブジェクトを使用しないでください。それが私が非常に混乱している理由です。 –

+0

その場合は、再利用しないでください、別のオブジェクトを再利用しています。あなたが私たちに関連するコードを表示していないので、どちらを教えてもらえません。 –

関連する問題