Bug 56585 - Failure in sheet.autoSizeColumn()
Summary: Failure in sheet.autoSizeColumn()
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.10-FINAL
Hardware: Other Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-02 20:06 UTC by michael.melamed
Modified: 2014-06-02 21:04 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description michael.melamed 2014-06-02 20:06:41 UTC
I have an issue with invoking the autoSizeColumn() method in poi-ooxml-3.10-FINAL-20140208.jar.

In my code after I'm done generating the data,  I want to auto-resize all the columns,  so I have a very simple routine: 

for(int i = 0; i < 5; i++) {
  sheet.autoSizeColumn(i);
}

When this code runs on the server, the first call to sheet.autoSizeColumn(i) results in an error:

Exception in thread "main" java.lang.Error: Probable fatal error:No fonts found.
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1090)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
        at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
        at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
        at sun.font.FontManager.findDeferredFont(FontManager.java:918)
        at sun.font.FontManager.findFont2D(FontManager.java:1915)
        at sun.font.FontManager.findFont2D(FontManager.java:1876)
        at java.awt.Font.getFont2D(Font.java:477)
        at java.awt.Font.canDisplayUpTo(Font.java:2038)
        at java.awt.font.TextLayout.singleFont(TextLayout.java:469)
        at java.awt.font.TextLayout.<init>(TextLayout.java:527)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:208)
        at org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:386)
        at org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:369)
        at com.poi.mor.writers.MORVirtDetailsExcelWriter.recalcWidthsESTATE_EFF_DEV_VIRT_MAIN(MORVirtDetailsExcelWriter.java:277)



I finally was able to resolve this issue by installing some fonts on the server issuing the command:

yum install dejavu-lgc-fonts
Comment 1 Nick Burch 2014-06-02 20:24:45 UTC
In order to size the column, POI needs to work out how much space each letter takes up, which in turn means using the Java font libraries to calculate the spacing. As such, having fonts both installed *and* available to the JVM is a requirement for this to work.
Comment 2 Robert Kish 2014-06-02 21:04:04 UTC
(In reply to michael.melamed from comment #0)
> I have an issue with invoking the autoSizeColumn() method in
> poi-ooxml-3.10-FINAL-20140208.jar.
> 
> In my code after I'm done generating the data,  I want to auto-resize all
> the columns,  so I have a very simple routine: 
> 
> for(int i = 0; i < 5; i++) {
>   sheet.autoSizeColumn(i);
> }
> 
> When this code runs on the server, the first call to sheet.autoSizeColumn(i)
> results in an error:
> 
> Exception in thread "main" java.lang.Error: Probable fatal error:No fonts
> found.
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1090)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1073)
>         at sun.font.FontManager.initialiseDeferredFont(FontManager.java:962)
>         at sun.font.FontManager.findOtherDeferredFont(FontManager.java:901)
>         at sun.font.FontManager.findDeferredFont(FontManager.java:918)
>         at sun.font.FontManager.findFont2D(FontManager.java:1915)
>         at sun.font.FontManager.findFont2D(FontManager.java:1876)
>         at java.awt.Font.getFont2D(Font.java:477)
>         at java.awt.Font.canDisplayUpTo(Font.java:2038)
>         at java.awt.font.TextLayout.singleFont(TextLayout.java:469)
>         at java.awt.font.TextLayout.<init>(TextLayout.java:527)
>         at
> org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:208)
>         at
> org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:386)
>         at
> org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:369)
>         at
> com.poi.mor.writers.MORVirtDetailsExcelWriter.
> recalcWidthsESTATE_EFF_DEV_VIRT_MAIN(MORVirtDetailsExcelWriter.java:277)
> 
> 
> 
> I finally was able to resolve this issue by installing some fonts on the
> server issuing the command:
> 
> yum install dejavu-lgc-fonts

Another workaround that I have used is to set headless mode: http://mail-archives.apache.org/mod_mbox/poi-user/200705.mbox/%3C15719338671.20070504144714@dinom.ru%3E