Jump to content
  • ArrayIndexOutOfBoundsException in ParagraphUtil.getFirstTabStop


    Jago Pauwels
    Assigned User teodord
    CategoryBug report
    PriorityNormal
    ReproducibilitySometimes
    ResolutionFixed
    SeverityMajor
    StatusResolved
    Versionv4.7.1

    I've made a report to export some data to csv, containing text fields with width 20 and Stretch With Overflow on.

    When a text field contains a tab character I get the following exception:

     

    java.lang.ArrayIndexOutOfBoundsException: 0

        at net.sf.jasperreports.engine.util.ParagraphUtil.getFirstTabStop(ParagraphUtil.java:208)      at net.sf.jasperreports.engine.fill.TextMeasurer.renderNextLine(TextMeasurer.java:1023)      at net.sf.jasperreports.engine.fill.TextMeasurer.renderParagraph(TextMeasurer.java:717)      at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:416)      at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:504)      at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:593)      at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328)      at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:377)      at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:351)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2039)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:301)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:148)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822)      at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61)      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

     

    Possible workarounds are:

    * Make the width of the text field bigger than 40

    * Decrease net.sf.jasperreports.default.tab.stop.width, the default value is 40

    * Avoid tabs by changing the query: change "field" into "replace(field, CHR(9))"

     

    These people have the same issue:

    * http://community.jaspersoft.com/questions/541804/arrayindexoutofboundsexception-paragraphutilgetfirsttabstop-multicolums-and-wrapped

    * http://community.jaspersoft.com/questions/541156/preview-error-412-and-413-arrayindexoutofbounds



    User Feedback

    Recommended Comments

    Changed Assigned User from - to @User_306070


    I got the same problem.Making the bellow change to source code (net.sf.jasperreports.engine.util.ParagraphUtil.getFirstTabStop) seems to solve the issue. Maybe some jasper developer could check it. In my environment, version-5.1.0, the code proposed works! public static TabStop getFirstTabStop(JRParagraph paragraph, float endX) { TabStop firstTabStop = new TabStop(); TabStop[] tabStops = getTabStops(paragraph, endX); // Old code. //firstTabStop = tabStops[0]; // New proposed code: if (tabStops.length > 0) { firstTabStop = tabStops[0]; } else { firstTabStop.setPosition((int)endX); } return firstTabStop; }
    Link to comment
    Share on other sites

    I added this line of code before calling JasperFillManager.fillReport() to work around this bug:

    JRProperties.setProperty(JRParagraph.DEFAULT_TAB_STOP_WIDTH, "10");

    Link to comment
    Share on other sites

    Changed Reproducibility from Always to Unable to Reproduce

    Changed Resolution from Open to Unable to Reproduce

    Changed Status from New to Resolved

    Changed Assigned User from @anonymous to -


    Unable to reproduce with version 6.4
    Link to comment
    Share on other sites

    Changed Severity from Minor to Major

    Changed Reproducibility from Unable to Reproduce to Sometimes

    Changed Resolution from Unable to Reproduce to Fixed


    I resolved this issue deleting the static text in headers and puting it again.Edit: Version 6.0.0
    Link to comment
    Share on other sites


×
×
  • Create New...