The Fop instance (unlike the Driver class in 0.20.5) is not supposed to
be reused. We will later add an environment class which will encapsulate
all the reusable parts of Fop as part of future optimization work. I
guess we should add a safe-guard that "one-use" components like the
FOTreeBuilder instance prepared by the Fop class are not used more than
once to avoid side-effects like you experienced. I'll see to that
tomorrow.

See also: http://xmlgraphics.apache.org/fop/0.91/embedding.html#object-reuse

On 26.01.2006 22:39:27 Steve Roy wrote:
> Hi,
> 
> Thanks for the help Jeremias.
> 
> Command line worked fine.  The problems seems to occur when running embedded 
> when the same FOP instance is called repeatedly for the multiple pdf 
> generations.  Is there some kind of reset method that needs to be called on 
> FOP?
> 
> We debugged and pdfDoc was null in stopRenderer on the subsequent call:
> 
>     public void stopRenderer() throws IOException {
>         pdfDoc.getResources().addFonts(pdfDoc, fontInfo);
>         pdfDoc.outputTrailer(ostream);
> 
>         this.pdfDoc = null;
>         ostream = null;
> 
>         pages = null;
> 
>         pageReferences.clear();
>         pvReferences.clear();
>         pdfResources = null;
>         currentStream = null;
>         currentContext = null;
>         currentPage = null;
>         currentState = null;
>         currentFontName = "";
>     }
> 
> 
> - steve
> 
> 
> 
> From: Jeremias Maerki <[EMAIL PROTECTED]>
> Reply-To: [email protected]
> To: [email protected]
> Subject: Re: NullPointerExceptions
> Date: Thu, 26 Jan 2006 15:19:21 +0100
> 
> Information about configuring the logging backend can be found in [1].
> Mostly we defer to the Jakarta Commons Logging documentation for that.
> If you work with JDK 1.4 and later JCL logs to the Java Logging API by
> default.
> 
> [1] http://xmlgraphics.apache.org/fop/0.91/embedding.html#basic-logging
> 
> In your case, however, I don't think that a lot of logging will help a
> lot. That's a pretty unusual exception. The NPE happens in
> PDFRenderer.stopRenderer() on the line where the font resources are
> added to the PDF. It looks like out of some weird reason the pdfDoc
> variable is null again. I can only imagine this happening if the SAX
> endDocument() method is called twice by the Transformer. I know that
> certain Xalan versions don't always issue the right SAX events. Maybe
> you hit such a problem.
> 
> Here's what I would do: Run your current document from the FOP
> command-line and check if the same problem occurs. Setup FOP so you can
> debug FOP and set a breakpoint in PDFRenderer.stopRenderer() and check
> how many times this method is called. For a single rendering run, this
> method must be called exactly once, not more, not less.
> 
> If my suspicion is right, try upgrading to the latest Xalan-J release.
> If that doesn't help, get back here.
> 
> Good luck!
> 
> On 26.01.2006 15:03:35 Steve Roy wrote:
>  > Hello,
>  >
>  > I find I am only presented with NullPointerExceptions from FOP when there 
> is
>  > some type of problem with the rendering.  I haven't noticed any info on
>  > turning on verbose logging or something of the sort.  Any suggestions on
>  > troubleshooting problems with the source xml or xslt?
>  >
>  > As an example, here is the current stack trace I am receiving:
>  >
>  > javax.xml.transform.TransformerException: java.lang.NullPointerException
>  > at
>  > 
> org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1276)
>  > at
>  > 
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
>  > at
>  > 
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
>  > at
>  > 
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
>  > at com.myco.myapp.xslfo.FOEngineFacadeFOP.transform(Unknown Source)
>  > at com.myco.myapp.xslfo.FOTransformer.transform(Unknown Source)
>  > at
>  > 
> com.myco.myapp.businessservice.ejb.DocumentGenerationServiceBeanEJB.getPDFForItem(Unknown
>  > Source)
>  > at
>  > 
> com.myco.myapp.businessservice.docgen.DocumentGenerationService.getPDFForItem(Unknown
>  > Source)
>  > Caused by: java.lang.NullPointerException
>  > at 
> org.apache.fop.render.pdf.PDFRenderer.stopRenderer(PDFRenderer.java:266)
>  > at
>  > 
> org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:228)
>  > at 
> org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:326)
>  > at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:246)
>  > at
>  > 
> org.apache.xalan.transformer.ResultTreeHandler.endDocument(ResultTreeHandler.java:192)
>  > at
>  > 
> org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1224)
>  >
>  > - steve
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to