Bug 47341 - FOP ClassLoader issues
Summary: FOP ClassLoader issues
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: 0.95
Hardware: PC All
: P3 normal
Target Milestone: ---
Assignee: fop-dev
Depends on:
Reported: 2009-06-09 17:45 UTC by Brendon Matthews
Modified: 2012-04-07 01:52 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Brendon Matthews 2009-06-09 17:45:01 UTC
I have built a custom Java server application that is used to host multiple websites, some of which currently use FOP-0.20.5 for PDF generation. However, I would like to start using FOP-0.95 for a new site i'm building, and have encountered a problem:

java.lang.ClassCastException: org.apache.fop.fo.UnknownXMLObj
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:281)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:163)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)

I think this has something to do with the ClassLoader setup, because the PDF file generates without any issues on all FOP versions when I try to generate it from a simple Java application.

So I did some more research, and created a new test java application which loads a bunch of jar files into a special ClassLoader object, loads a Runnable class from the ClassLoader with Class.forName(), and then executes it.

I then wrote a simple Runnable object for both FOP-0.20.5 and FOP-0.95 and built them into different jar files with the intention to keep them separate and ensure they belong to the same ClassLoader as the associated FOP libraries.

Now for the test:
FOP-0.20.5: PDF generated without any problems.
FOP-0.95: Failure. Same error as above.

Has anyone else encountered this sort of problem?

If there is no solution for this then it looks like I will be restricted to only one version of FOP for each server, and will be forced to load all the libraries in the java command line. If this is the case, I have a LOT of old xsl-fo files to rewrite to comply with FOP-0.95! :(
Comment 1 Glenn Adams 2012-04-07 01:37:13 UTC
resetting severity from major to normal pending further review
Comment 2 Glenn Adams 2012-04-07 01:45:03 UTC
resetting P2 open bugs to P3 pending further review