xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iain Soedring <IAINS...@uk.ibm.com>
Subject FOP failing to transform XSL to PDF with image when run in tomcat/osgi, but working when run in standalone
Date Mon, 24 Nov 2014 15:53:17 GMT

I have an xsl file that includes an external image:

<fo:external-graphic src="/images/BrandGraphic.PNG"/>

When running as a standalone Java application the transformer.transform 
function works, and I get a valid PDF file.

When running in Tomcat/OSGI, on the same server (same JRE), I get the 
following error:

FATAL ERROR:  'java.lang.IllegalArgumentException: Unknown function: 
           :Unknown function: gatherContextInfo

If I remove the image from the XSL, everything works.

I checked in the fop 1.0 source, and see that this comes from 


        public FunctionPart(String functionName) {
            this.function = getFunction(functionName);
            if (this.function == null) {
                throw new IllegalArgumentException("Unknown function: " + 

Unfortunately no stack trace is output when catching this exception, and 
tracing back through the code I can see various places from where this 
could have got called.

the 'gatherContextInfo' function itself is in 
org.apache.fop.fo.FONode.java, and is overridden in sub-classes.

On the class-loading side, I've verified that the same jars are loaded in 
both tomcat and standalone.  The following are the ones that I find are 
essential for my transform to work:

avalon, batik, commons-io, commons-logging, xmlgraphics.

On tomcat there are many more libraries loaded, but the only overlap I can 
see is commons-logging, where my war file already uses a different version 
of this.

I have asked the same question on stackoverflow: 
, but I haven't get much response beyond what I'd already looked at so 

One other issue I found running FOP in Tomcat/OSGI, was the need to 
override the PDF renderer, with this code:

                FOUserAgent useragent = fopFactory.newFOUserAgent();
                PDFRenderer pdfrenderer = new PDFRenderer();

                fopFactory.addElementMapping(new FOElementMapping());
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, useragent, out);

otherwise the code would fail with:

 Caused by: java.lang.UnsupportedOperationException: Don't know how to 
handle "application/pdf" as an output format. Neither an FOEventHandler, 
nor a Renderer could be found for this output format.

Does anyone have any idea what could be going wrong here?

Best Regards,

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

View raw message