Jump to content
  • NullPointer in JRDataUtils getLocaleCode


    C-Box
    Assigned User lucianc
    CategoryBug report
    PriorityHigh
    ReproducibilityAlways
    ResolutionFixed
    SeverityMajor
    StatusClosed

    Hi,

     

    I just got an nullpointen exception, when exporting a report to XLS...

     

    here is the stacktrace:

     

    java.lang.NullPointerException

     

    *** Methoden-Stack ***

    net.sf.jasperreports.engine.util.JRDataUtils.getLocaleCode (Zeile 44)

    net.sf.jasperreports.engine.JRAbstractExporter.getNumberFormat (Zeile 1013)

    net.sf.jasperreports.engine.JRAbstractExporter.getNumberCellValue (Zeile 935)

    net.sf.jasperreports.engine.JRAbstractExporter.getTextValue (Zeile 843)

    net.sf.jasperreports.engine.export.JRXlsExporter.createTextCell (Zeile 341)

    net.sf.jasperreports.engine.export.JRXlsExporter.exportText (Zeile 332)

    net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage (Zeile 545)

    net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream (Zeile 421)

    net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport (Zeile 221)

     

    I already searched the forum and the tracker and the sources... I think in JRDataUtils method "protected Locale getTextLocale(JRPrintText text)" the method shouldn't return NULL as this returnvalue is evalueted on other methods like getNumberFormat and getLocaleCode.

     

    perhaps the method should better return the standard locale if it can't found one...

     

    like this:

     

    protected Locale getTextLocale(JRPrintText text)

    {

    String localeCode = text.getLocaleCode();

    if (localeCode == null)

    {

    localeCode = jasperPrint.getLocaleCode();

    }

    return localeCode == null ? JRDataUtils.getLocale(Locale.getDefault()): JRDataUtils.getLocale(localeCode);

    }

     

     

     

     

    What do you think

    regards from cloudy Germany

    C-Box



    User Feedback

    Recommended Comments

    By the way,

     

    just found this in JRAbstractExporter with the cache... surely just a Copy&Paste Error:

     

    The NumberFormat is put in the DateFormatCache and not in the NumberFormatCache as it\'s looked for before

     

    String key = formatFactoryClass

    + "|" + pattern

    + "|" + JRDataUtils.getLocaleCode(lc);

    NumberFormat numberFormat = (NumberFormat)numberFormatCache.get(key);

    if (numberFormat == null)

    {

    FormatFactory formatFactory = DefaultFormatFactory.createFormatFactory(formatFactoryClass);//FIXMEFORMAT cache this too

    numberFormat = formatFactory.createNumberFormat(pattern, lc);

    dateFormatCache.put(key, numberFormat);

    }

    return numberFormat;

     

     

    C-Box

    Link to comment
    Share on other sites


×
×
  • Create New...