MohamedSaeed / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

NullPonterException when I make a mistake in my document DOCX #424

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
With the velocity template, create a field containing #if and a variable 
without the dollar sign:

#if (MyVarWithoutDollar)
#end

What is the expected output? What do you see instead?

The expected exception must be:
 org.apache.velocity.runtime.parser.TemplateParseException: Encountered "MyVarWithoutDollar" at word/document.xml[line 1, column 35924]
Was expecting one of:
    "[" ...
    "{" ...
    "(" ...
    <WHITESPACE> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <IDENTIFIER> ...
    "{" ...
    <WHITESPACE> ...

The obtains exception is:
java.lang.NullPointerException
    at fr.opensagres.xdocreport.document.docx.preprocessor.sax.RBufferedRegion.setTContent(RBufferedRegion.java:65)
    at fr.opensagres.xdocreport.document.docx.preprocessor.sax.PBufferedRegion.process(PBufferedRegion.java:216)
    at fr.opensagres.xdocreport.document.docx.preprocessor.sax.DocxBufferedDocument.onEndEndElement(DocxBufferedDocument.java:320)
    at fr.opensagres.xdocreport.document.preprocessor.sax.BufferedDocumentContentHandler.endElement(BufferedDocumentContentHandler.java:273)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:596)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:673)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1645)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
    at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
    at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
    at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1196)
    at __redirected.__XMLReaderFactory.parse(__XMLReaderFactory.java:183)
    at fr.opensagres.xdocreport.document.preprocessor.sax.SAXXDocPreprocessor.preprocess(SAXXDocPreprocessor.java:62)
    at fr.opensagres.xdocreport.document.preprocessor.sax.SAXXDocPreprocessor.preprocess(SAXXDocPreprocessor.java:47)
    at fr.opensagres.xdocreport.document.preprocessor.AbstractXDocPreprocessor.preprocess(AbstractXDocPreprocessor.java:88)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.doPreprocessorIfNeeded(AbstractXDocReport.java:366)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:512)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:487)

What version of the product are you using? On what operating system?
1.0.4

Please provide any additional information below.

This null pointer prevents us from finding the exact location of the error if 
the file is large. To correct this, simply edit the method setTContent of the 
class
fr.opensagres.xdocreport.document.docx.preprocessor.sax.RBufferedRegion
with:
    public void setTContent(String tContent) {
        BufferedElement tRegion = getTRegion();
        if (tRegion != null)
            tRegion.setTextContent(tContent);
    }

Original issue reported on code.google.com by gueri...@free.fr on 17 Jul 2014 at 10:25

GoogleCodeExporter commented 9 years ago
Please post your docx and your Java code which causes your problem.

Original comment by angelo.z...@gmail.com on 7 Aug 2014 at 3:28

GoogleCodeExporter commented 9 years ago
Could you please retry with 1.0.5-SNAPSHOT. 

I have tested with your explanation and it works like it's expected (no NPE but 
Velocity error).

Thank's

Original comment by angelo.z...@gmail.com on 7 Aug 2014 at 8:22

GoogleCodeExporter commented 9 years ago
I also no longer able to reproduce the problem, and I did not find the version 
of my file that caused the problem, sorry.

Original comment by gueri...@free.fr on 11 Aug 2014 at 1:16

GoogleCodeExporter commented 9 years ago
Ok I close this isse. Thank's for your answer.

Original comment by angelo.z...@gmail.com on 11 Aug 2014 at 1:25

GoogleCodeExporter commented 9 years ago
cleanup

Original comment by pascal.leclercq on 10 Oct 2014 at 7:37