You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2012/10/29 08:44:25 UTC

[Bug 54061] New: NullPointer Exception in org.apache.fop.fo.FObj

https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

          Priority: P2
            Bug ID: 54061
          Assignee: fop-dev@xmlgraphics.apache.org
           Summary: NullPointer Exception in org.apache.fop.fo.FObj
          Severity: normal
    Classification: Unclassified
          Reporter: spao001@gmail.com
          Hardware: PC
            Status: NEW
           Version: 1.1
         Component: general
           Product: Fop

In the method public void removeChild(FONode child) {... i get a
NullPointerException at row FObj:250;
I have seen the code:

...
        if (child == lastChild) {
            if (child.siblings != null) {  // row 249
                lastChild = siblings[0];   // row 250
            } else {
                lastChild = null;
            }
        }
...

the row 250 should be lastChild = child.siblings[0] instead of siblings[0] ???

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #5 from spao <sp...@gmail.com> ---
Created attachment 29534
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29534&action=edit
FO File that generates the error

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #7 from Glenn Adams <ga...@apache.org> ---
in any case, no matter how broken the FO input, FOP shouldn't be throwing NPEs,
so there is an FOP bug to fix... the reporter needs to find the minimal
(reduced) test that produces the NPE

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #4 from spao <sp...@gmail.com> ---
Created attachment 29533
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29533&action=edit
test class to reproduce the error

Test Class with main method.
Takes as input the FO file and a boolean strictValidation.
If strictValidation = true gives a standard error of grammar, if it is false
instead gives NullPointer on FObj.java

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

Chris Bowditch <bo...@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #3 from Chris Bowditch <bo...@hotmail.com> ---
Is that because of confidentially? If so, please replace the sensitive text
with a string of XXX or similar. I'm updating this bug to Needs Info status

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #12 from spao <sp...@gmail.com> ---
(In reply to comment #10)
> (In reply to comment #8)
> > there is a FOP option to create a FO file indented, which indicates the
> > position of errors based on the file indented?
> 
> FOP does not produce FO, this is the matter of XSLT engine.
> For convenience, FOP comes with xalan.
> 
> See [1] to tweak your XSLT if you use xalan.
> 
> [1] http://xml.apache.org/xalan-j/usagepatterns.html#outputprops

Ok, thanks, solved.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #9 from Robert Meyer <rm...@hotmail.co.uk> ---
Created attachment 29535
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29535&action=edit
Attached a version of the FO which has been formatted.

I ran through the FO using xml_pp (pretty print) in Linux to create the
attached output. This probably isn't helpful to you as you are using XSLT and
is likely to change. The other alternative may be to use something like:

<xsl:if test="<tag>">
  <fo:table>
  ...
  <xsl:apply-templates select="<tag>"/>
  </fo:table>
</xsl:if>

This way you can check to see if the data exists before adding the table.

With regard to outputting formatted FO, I am not sure on that but maybe someone
else will know.

Glen, with regard to adding a smaller example, i'll see if I can replicate the
same behaviour by creating a table with an empty table-body. If so, i'll upload
that when I get a chance.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #11 from Robert Meyer <rm...@hotmail.co.uk> ---
Created attachment 29539
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29539&action=edit
Smaller FO to reproduce the nullpointer

I have attached a smaller example which reproduces the nullpointer reported in
the original post when using the -r flag.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #10 from Pascal Sancho <ps...@gmail.com> ---
(In reply to comment #8)
> there is a FOP option to create a FO file indented, which indicates the
> position of errors based on the file indented?

FOP does not produce FO, this is the matter of XSLT engine.
For convenience, FOP comes with xalan.

See [1] to tweak your XSLT if you use xalan.

[1] http://xml.apache.org/xalan-j/usagepatterns.html#outputprops

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

Robert Meyer <rm...@hotmail.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Robert Meyer <rm...@hotmail.co.uk> ---
Would it be possible for you to post an example FO file (and xconf if
necessary) to reproduces this error. This will help us investigate why this is
happening and also what needs to be done in order to resolve it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

spao <sp...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #8 from spao <sp...@gmail.com> ---
(In reply to comment #6)
> Hi,
> 
> Initially I tried going through the code and implementing the fix you
> suggested which does appear to be incorrect in the source, but unfortunately
> it trips up later on with another null pointer exception. I then put in a
> check for that to avoid it but I got a further NoSuchElement exception. It
> was at this stage I looked at the FO and the validation warnings I tried to
> circumvent by using the -r flag. It appears there is a lot wrong with the
> file. The warnings / errors are all like the following:
> 
> "fo:table-body" is missing child elements. Required content model: marker*
> (table-row+|table-cell+) (See position 895:37)
> 
> After looking through the FO there were numerous instances of tables with
> table-body elements with no contents or similarly declared empty
> table-headers. These are rules which both FOP and the FO must abide [1], so
> I can see why FOP is falling over. I went through the FO removing all of the
> blank tables with the problematic body and header's elements. After I had
> done this I could successfully render the document. It may not be how it was
> intended to look, but it did render. 
> 
> In order to get yours to render, I would recommend going through the FO file
> and instead of removing the tables, add the necessary missing table-rows /
> table-cells if these are used for formatting purposes. This should prevent
> FOP from complaining whilst allowing you to render the document correctly.
> 
> [1] http://www.w3.org/TR/xsl/#fo_table-body
> 
> In the meantime, this bug can relate to the incorrect sublings usage you
> specified in your original post.

The fact is that I wanted to avoid to fix errors (example: fo: table-body
missing childs) in the FO because I thought that strictValidation = false
ignored them.
But since FOP gave me NullPointer, so I proceeded as you said, that I corrected
all errors as specified in http://www.w3.org/TR/xsl/,
but this cost me a lot of trouble because the FO file is generated on a few
lines, but very long, and therefore the error is of the type: "see position
3:56753"!
But how do I find the column 56753? and after that I found it how do I compare
it with my XSLT file that is indented?

All this to say:
there is a FOP option to create a FO file indented, which indicates the
position of errors based on the file indented?
Thanks a lot

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #2 from spao <sp...@gmail.com> ---
(In reply to comment #1)
> Would it be possible for you to post an example FO file (and xconf if
> necessary) to reproduces this error. This will help us investigate why this
> is happening and also what needs to be done in order to resolve it.

(In reply to comment #1)
> Would it be possible for you to post an example FO file (and xconf if
> necessary) to reproduces this error. This will help us investigate why this
> is happening and also what needs to be done in order to resolve it.

Sorry, i can't

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54061] NullPointer Exception in org.apache.fop.fo.FObj

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54061

--- Comment #6 from Robert Meyer <rm...@hotmail.co.uk> ---
Hi,

Initially I tried going through the code and implementing the fix you suggested
which does appear to be incorrect in the source, but unfortunately it trips up
later on with another null pointer exception. I then put in a check for that to
avoid it but I got a further NoSuchElement exception. It was at this stage I
looked at the FO and the validation warnings I tried to circumvent by using the
-r flag. It appears there is a lot wrong with the file. The warnings / errors
are all like the following:

"fo:table-body" is missing child elements. Required content model: marker*
(table-row+|table-cell+) (See position 895:37)

After looking through the FO there were numerous instances of tables with
table-body elements with no contents or similarly declared empty table-headers.
These are rules which both FOP and the FO must abide [1], so I can see why FOP
is falling over. I went through the FO removing all of the blank tables with
the problematic body and header's elements. After I had done this I could
successfully render the document. It may not be how it was intended to look,
but it did render. 

In order to get yours to render, I would recommend going through the FO file
and instead of removing the tables, add the necessary missing table-rows /
table-cells if these are used for formatting purposes. This should prevent FOP
from complaining whilst allowing you to render the document correctly.

[1] http://www.w3.org/TR/xsl/#fo_table-body

In the meantime, this bug can relate to the incorrect sublings usage you
specified in your original post.

-- 
You are receiving this mail because:
You are the assignee for the bug.