Bug 48765 - java.lang.NullPointerException: org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager.getChangedKnuthElements(InlineStackingLayoutManager.java:375)
Summary: java.lang.NullPointerException: org.apache.fop.layoutmgr.inline.InlineStackin...
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: all
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
: 53586 53955 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-02-18 11:40 UTC by Mathieu Malaterre
Modified: 2012-10-03 07:02 UTC (History)
4 users (show)



Attachments
fo file (39.60 KB, application/octet-stream)
2010-02-18 11:40 UTC, Mathieu Malaterre
Details
proposed patch (1.20 KB, patch)
2010-03-01 09:53 UTC, Mathieu Malaterre
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Malaterre 2010-02-18 11:40:55 UTC
Created attachment 25014 [details]
fo file

Here is my input docbook file:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
<article>
<section>
 <title>title</title>
<blockquote>
<para>
The <emphasis role="bold"><anchor
id="example.anchor.1"/>anchor</emphasis> element is empty and
contributes
nothing to the flow of the content in which it occurs.  It is only useful
as a target.
</para>
</blockquote>
</section>
</article>

which I process with:

/usr/bin/xsltproc --stringparam fop1.extensions 1 --stringparam
ulink.show 0 --xinclude -o test2.fo
/usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl test2.xml

and lead to:

$ ./fop test2.fo test2.pdf
Feb 17, 2010 2:52:18 PM org.apache.fop.apps.FOURIResolver resolve
SEVERE: Error with opening URL
'http://docbook.sourceforge.net/release/images/draft.png': Network is
unreachable
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:9588)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:10285)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:10980)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:11672)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:12361)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:13050)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:13736)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:14427)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:15118)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:15806)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:16496)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:17186)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:17873)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:18563)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:19253)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:19940)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:20631)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:21322)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI:
http://docbook.sourceforge.net/release/images/draft.png. (See position
2:22010)
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "Symbol,normal,700" not found. Substituting with
"Symbol,normal,400".
Feb 17, 2010 2:52:18 PM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with
"ZapfDingbats,normal,400".
Feb 17, 2010 2:52:18 PM org.apache.fop.cli.Main startFOP
SEVERE: Exception
java.lang.NullPointerException
       at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
       at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
       at org.apache.fop.cli.Main.startFOP(Main.java:174)
       at org.apache.fop.cli.Main.main(Main.java:205)

---------

java.lang.NullPointerException
       at org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager.getChangedKnuthElements(InlineStackingLayoutManager.java:375)
       at org.apache.fop.layoutmgr.inline.InlineLayoutManager.getChangedKnuthElements(InlineLayoutManager.java:537)
       at org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager.getChangedKnuthElements(InlineStackingLayoutManager.java:380)
       at org.apache.fop.layoutmgr.inline.InlineLayoutManager.getChangedKnuthElements(InlineLayoutManager.java:537)
       at org.apache.fop.layoutmgr.inline.LineLayoutManager.findHyphenationPoints(LineLayoutManager.java:1359)
       at org.apache.fop.layoutmgr.inline.LineLayoutManager.findOptimalBreakingPoints(LineLayoutManager.java:797)
       at org.apache.fop.layoutmgr.inline.LineLayoutManager.createLineBreaks(LineLayoutManager.java:763)
       at org.apache.fop.layoutmgr.inline.LineLayoutManager.getNextKnuthElements(LineLayoutManager.java:592)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:571)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:552)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:280)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:123)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:115)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:571)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:552)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:280)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:123)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:115)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:571)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:552)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:280)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:123)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:115)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:571)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:552)
       at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:280)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:123)
       at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:115)
       at org.apache.fop.layoutmgr.FlowLayoutManager.getNextChildElements(FlowLayoutManager.java:199)
       at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:140)
       at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:129)
       at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:70)
       at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:216)
       at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:692)
       at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:149)
       at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:132)
       at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:337)
       at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:85)
       at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:107)
       at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:238)
       at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
       at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
       at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)
       at org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1101)
       at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
       at org.apache.xerces.xinclude.XIncludeHandler.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:484)
       at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
       at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
       at org.apache.fop.cli.Main.startFOP(Main.java:174)
       at org.apache.fop.cli.Main.main(Main.java:205)
Comment 1 Mathieu Malaterre 2010-02-18 11:42:05 UTC
one possible way to work around this segfault is to pass the following to the xsltproc engine:


      --stringparam hyphenate 0
Comment 2 Georg Datterl 2010-02-18 11:54:25 UTC
This is the offending fo:block

<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" >
The <fo:inline font-weight="bold">
		<fo:inline id="example.anchor.1"/>anchor</fo:inline> element is empty and contributes
nothing to the flow of the content in which it occurs.  It is only useful
as a target.
</fo:block>

Adding hyphenate="false" to the fo:block avoids the NPE. 
Adding a text to the empty fo:inline avoids the NPE. 
Removing the id attibute avoids the NPE.
Comment 3 Vincent Hennebert 2010-02-18 12:10:52 UTC
Might have something to do with bug #46386
Comment 4 Mathieu Malaterre 2010-03-01 09:53:59 UTC
Created attachment 25073 [details]
proposed patch
Comment 5 Bela Hausmann 2010-05-23 15:07:18 UTC
(In reply to comment #4)
> Created an attachment (id=25073) [details]
> proposed patch

I patched my fop and then it worked, but this patch opens up this issue again: #42748, where a <fo:inline id="{$id}"/> cause a "WARNING: Page ?: Unresolved id reference "???" found."
Comment 6 Bela Hausmann 2010-05-23 15:34:47 UTC
I found a dirty workaround so that everything works 'till this is fixed:

Add this to your fo XSL file

<xsl:template match="anchor">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>
  <fo:inline id="{$id}"></fo:inline>
</xsl:template>

Note that there should be the ZERO WIDTH NO-BREAK SPACE unicode charater (U+FEFF) in the fo:inline tag (<fo:inline id="{$id}">U+FEFF</fo:inline>). A unicode font is probably needed for this to work.
Comment 7 Michel Krämer 2011-07-03 12:15:12 UTC
I'm also having problems with hyphenation and DocBook <anchor> tags. Do you already know when this bug will be resolved? Thanks!

Michel
Comment 8 Glenn Adams 2012-04-07 01:45:08 UTC
resetting P2 open bugs to P3 pending further review
Comment 9 Pascal Sancho 2012-07-23 11:20:38 UTC
*** Bug 53586 has been marked as a duplicate of this bug. ***
Comment 10 Pascal Sancho 2012-10-03 07:02:09 UTC
*** Bug 53955 has been marked as a duplicate of this bug. ***