xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <...@jeremias-maerki.ch>
Subject Re: Manually Configuring a PDFRenderer
Date Wed, 06 Jul 2011 06:27:29 GMT
On 06.07.2011 05:17:54 Brandon Youkstetter wrote:
> I put together a service that uses FOP to render PDF using FOP 1.0 on
> java 6. All worked perfectly when running in eclipse on my development
> environment. However, my requirements are for this service to run in a
> webMethods (8.2) IDE workflow (also runs on Java 6).
> 
> I setup the java service in webMethods placing the required libraries
> into directory that is loaded by the webMethods classloaders, but
> immediately ran into the following exception:
> 
> 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.
> 
> My guess is this problem stems from a failure to read
> the /META-INF/services/ properties files due to the way the webMethods
> classloaders are loading things up (please let me know if this
> assumption seems faulty). 

No, that is the most likely explanation.

> After searching through the mailing lists, I found a thread that seemed
> to discuss a similar issue. The submitter was having difficulty in lotus
> notes. This thread described a solution for manually configuring the
> PDFRenderer which I followed.
> 
> Specifically, I configured my fop factory with all the element mappings
> found in /META-INF/services/org.apache.fop.fo.ElementMapping like so:
> 
>     fopFactory = FopFactory.newInstance();
>     fopFactory.addElementMapping(new FOElementMapping());
>     fopFactory.addElementMapping(new SVGElementMapping());
>     fopFactory.addElementMapping(new BatikExtensionElementMapping());
>     fopFactory.addElementMapping(new ExtensionElementMapping());
>     fopFactory.addElementMapping(new InternalElementMapping());
>     fopFactory.addElementMapping(new OldExtensionElementMapping());
>     fopFactory.addElementMapping(new XMPElementMapping());
>     fopFactory.addElementMapping(new RDFElementMapping());
>     fopFactory.addElementMapping(new PSExtensionElementMapping());
>     fopFactory.addElementMapping(new AFPElementMapping());
>     fopFactory.addElementMapping(new PCLElementMapping());

Well, that's just one of the extension points. With that alone, you
don't have: the Renderers, the IFDocumentHandlers, the FOEventHandlers, the
ImageHandlers, the ContentHandlerFactories, etc. etc. And these are only
the extension points in FOP, not the ones in XML Graphics Commons. This
work-around may work if you somehow need to integrate a single plug-in
in some specific way, but that is just an awkward process. I recommend
to try and find a way to make the normal mechanism work. After all, it's
a standard mechanism of Java which should work in a traditional
hierarchical class loader setup. It quickly fails in an OSGi environment
where you have more of a network-oriented setup. Maybe webMethods does
something similar. I have no idea.

> Then I created a user agent to overwrite the Renderer like this:
> 
>     FOUserAgent ua = factory.newFOUserAgent();
>     PDFRenderer pdfRenderer = new PDFRenderer();
>     pdfRenderer.setUserAgent(ua);
>     ua.setRendererOverride(pdfRenderer);
>     fop = factory.newFop(MimeConstants.MIME_PDF, ua, output);
> 
> This setup got me past the UnsupportedOperationException in the
> RendererFactory and produced a result. However, the output is a 15 byte,
> seemingly invalid result which Ive attached.  

It would help if you gave a little more information (stack trace) on the
UnsupportedOperationException. From the attached PDF, I can tell that
the PDFRenderer started working but then probably got interrupted by an
exception, probably that UnsupportedOperationException.

> What am I missing? Why am I getting this strange result? Any help would
> be greatly appreciated. 

A quick search reveals a document on webMethods class loaders:
http://communities.softwareag.com/ecosystem/communities/public/Developer/webmethods/downloads/ESBandIntegration/ISClassLoading

Maybe that helps you set up everything correctly. The FOP, Batik and XML
Graphics Commons JAR should all be setup so they are loaded by the same
class loader. The Services class in XML Graphics Commons can only to
"see" the JARs in the same class loader or in any of the parent/ancestor
class loaders. In the worst case, you have to think about setting up
your own class loader. You could get some inspiration for that from
here:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java?view=markup

HTH

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message