Bug 41426 - FOP dies with ClassCastException in org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements
Summary: FOP dies with ClassCastException in org.apache.fop.layoutmgr.FlowLayoutManage...
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: general (show other bugs)
Version: 0.93
Hardware: Other Windows XP
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-21 06:35 UTC by Julian Reschke
Modified: 2012-04-01 06:51 UTC (History)
1 user (show)



Attachments
Test case (62.42 KB, application/octet-stream)
2007-01-21 06:37 UTC, Julian Reschke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Reschke 2007-01-21 06:35:20 UTC
In my tests, FOP 0.93 dies with a ClassCastException in
org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements:

21.01.2007 15:34:58 org.apache.fop.cli.Main startFOP
SCHWERWIEGEND: Exception
java.lang.ClassCastException
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:168)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
	at org.apache.fop.cli.Main.startFOP(Main.java:160)
	at org.apache.fop.cli.Main.main(Main.java:191)

---------

java.lang.ClassCastException
	at
org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:76)
	at
org.apache.fop.layoutmgr.PageSequenceLayoutManager$PageBreaker.getNextKnuthElements(PageSequenceLayoutManager.java:272)
	at
org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:554)
	at
org.apache.fop.layoutmgr.PageSequenceLayoutManager$PageBreaker.getNextBlockList(PageSequenceLayoutManager.java:264)
	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:301)
	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:263)
	at
org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:157)
	at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:385)
	at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:148)
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:378)
	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:194)
	at
org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1050)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:452)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
	at org.apache.fop.cli.Main.startFOP(Main.java:160)
	at org.apache.fop.cli.Main.main(Main.java:191)

(will attach test file)
Comment 1 Julian Reschke 2007-01-21 06:37:39 UTC
Created attachment 19439 [details]
Test case

This test input shows the bug, when run under JDK 1.4, producing PDF output.
Comment 2 Adrian Cumiskey 2007-01-21 07:27:38 UTC
I reported this problem with one of the fop examples
(examples/fo/advanced/cid-fonts.fo) last week.  The following patch fix the
exception.

--- snip ---

C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
===================================================================
---
C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
(revision 497065)
+++
C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
(working copy)
@@ -69,11 +69,11 @@
         int flowBPD = (int) getCurrentPV().getBodyRegion().getBPD();

         // currently active LM
-        BlockLevelLayoutManager curLM;
+        LayoutManager curLM;
         LinkedList returnedList;
         LinkedList returnList = new LinkedList();

-        while ((curLM = ((BlockLevelLayoutManager) getChildLM())) !=
null) {
+        while ((curLM = getChildLM()) != null) {
             if (curLM instanceof InlineLevelLayoutManager) {
                 log.error("inline area not allowed under flow -
ignoring");
                 curLM.setFinished(true);

--- snip ---

Adrian
Comment 3 Adrian Cumiskey 2007-01-21 07:34:08 UTC
I am new to the Apache FOP project and do not have commit rights yet so have
reassiged this bug to owner.
Comment 4 Jeremias Maerki 2007-01-22 14:42:42 UTC
Patch applied. Thanks, Adrian!
http://svn.apache.org/viewvc?view=rev&rev=498835

Please note that while Adrian's fix removes the ugly ClassCastException,
fo:wrapper will still not fully work as expected. You can use it to set
inheritable properties but setting an "id" attribute will not have the desired
effect. It will simply be ignored. The test wrapper_block_id.xml shows this.

So, Julian, you will not be able to use fo:wrapper like you did in your example
file for now. Please use an empty fo:block instead.

I'm not sure how best to solve the "id" problem. Maybe something with an LM
checking whether its parent is a wrapper. Suggestions welcome. Anyway, I'm
closing this bug as this was about the ClassCastException and we're rid of that.
Comment 5 Andreas L. Delmelle 2007-01-23 09:45:32 UTC
FYI: Adrian recently discovered that one of our examples generates SEVERE errors due to the usage of 
fo:wrapper as direct descendant of the fo:flow (= advanced/cid-fonts.fo)

The reason being the bare white-space node descendants of the wrapper --ultimately collapsed, that's 
true, but whitespace handling is done later...

As a workaround there, the usage of fo:wrapper could easily be avoided, I think, because it is merely used 
for inherited properties... These might as well be specified on the fo:flow itself, and overridden only for 
the trailing fo:table (which is not enclosed by the fo:wrapper), if necessary.
Comment 6 Glenn Adams 2012-04-01 06:51:03 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed